<?php


namespace app\admin\controller\develop;


use app\admin\controller\Controller;
//use think\Controller;
use app\admin\model\BaseSetting;
use app\api\model\User;
use app\common\exception\BaseException;
use app\common\library\wechat\Abonus;
use app\common\library\wechat\WxPay;
use app\common\model\dealer\Capital;
use app\common\model\user\BalanceLog;
use app\common\model\Wxapp as WxappModel;
use think\Db;
use utils\Services;
use utils\SnowFlake;

class Joggle extends \think\Controller
{
    public function dson1(){
        $params=$this->request->param();
//        $dataList=db('divide_receives')->where(['wxapp_id'=>$params['id'],'periods_num'=>$params['num'],'type'=>0])->field('receives_id')->order('receives_id asc')->select();
//        $this->log('分账用户',$dataList);
        $jsarr = '[{"receives_id":2916,"user_id":14995,"account":"oYUO75RUXWLFP1JvMa8K9TFidVuc","order_no":"2020111810054541","wxapp_id":43,"payment":"477.00","periods_num":1000,"transaction_id":"4200000821202011185888919414","balance":"362.89","top_limit":"477.00","total_abonus":"114.11","type":0,"times":241,"create_time":1605685413,"update_time":1606992658,"reward_money":"34.33","refund_money":"58.32","finish_time":1608277413,"small_change":"0.00"},{"receives_id":2919,"user_id":14979,"account":"oYUO75ZU62qoQPmGZnK47fr2t7Qw","order_no":"2020111856995098","wxapp_id":43,"payment":"289.00","periods_num":1000,"transaction_id":"4200000819202011186746952671","balance":"196.35","top_limit":"289.00","total_abonus":"92.65","type":0,"times":240,"create_time":1605687678,"update_time":1606992658,"reward_money":"33.79","refund_money":"50.19","finish_time":1608279678,"small_change":"0.00"},{"receives_id":2921,"user_id":15059,"account":"oYUO75V4KGRRfUK9Txa-sht1S3b8","order_no":"2020111810254561","wxapp_id":43,"payment":"138.00","periods_num":1000,"transaction_id":"4200000843202011184767067000","balance":"54.02","top_limit":"138.00","total_abonus":"83.98","type":0,"times":239,"create_time":1605690038,"update_time":1606992658,"reward_money":"33.34","refund_money":"47.54","finish_time":1608282038,"small_change":"0.00"},{"receives_id":2922,"user_id":15089,"account":"oYUO75Z6OVlTxmYiMJyVeAfSqRHw","order_no":"2020111856531021","wxapp_id":43,"payment":"141.00","periods_num":1000,"transaction_id":"4200000815202011185495170940","balance":"60.12","top_limit":"141.00","total_abonus":"80.88","type":0,"times":238,"create_time":1605692156,"update_time":1606992658,"reward_money":"32.94","refund_money":"45.41","finish_time":1608284156,"small_change":"0.00"},{"receives_id":2928,"user_id":15111,"account":"oYUO75SuHKTHVA2E9gz5d_3PcJqc","order_no":"2020111810150551","wxapp_id":43,"payment":"225.00","periods_num":1000,"transaction_id":"4200000818202011185122523652","balance":"146.65","top_limit":"225.00","total_abonus":"78.35","type":0,"times":237,"create_time":1605694531,"update_time":1606992658,"reward_money":"32.58","refund_money":"42.40","finish_time":1608286531,"small_change":"0.00"},{"receives_id":2932,"user_id":15126,"account":"oYUO75bne7uCnb3WMYKcTsM66J9s","order_no":"2020111897100535","wxapp_id":43,"payment":"372.00","periods_num":1000,"transaction_id":"4200000843202011189405913348","balance":"298.53","top_limit":"372.00","total_abonus":"73.47","type":0,"times":235,"create_time":1605695999,"update_time":1606992658,"reward_money":"32.19","refund_money":"36.50","finish_time":1608287999,"small_change":"0.00"},{"receives_id":2946,"user_id":15151,"account":"oYUO75T04f95QFZHOGh80WKvbLxY","order_no":"2020111899999857","wxapp_id":43,"payment":"237.00","periods_num":1000,"transaction_id":"4200000816202011184030199441","balance":"168.31","top_limit":"237.00","total_abonus":"68.69","type":0,"times":234,"create_time":1605698276,"update_time":1606992658,"reward_money":"31.88","refund_money":"34.15","finish_time":1608290276,"small_change":"0.00"},{"receives_id":2958,"user_id":15170,"account":"oYUO75UY2NGsNjR64PNfmO1jj_2M","order_no":"2020111857995610","wxapp_id":43,"payment":"187.00","periods_num":1000,"transaction_id":"4200000819202011180747383016","balance":"120.97","top_limit":"187.00","total_abonus":"66.03","type":0,"times":233,"create_time":1605699988,"update_time":1606992658,"reward_money":"31.62","refund_money":"32.54","finish_time":1608291988,"small_change":"0.00"},{"receives_id":2966,"user_id":13712,"account":"oYUO75ZTsRAJZcqLW1NPWANrW77M","order_no":"2020111849564957","wxapp_id":43,"payment":"167.00","periods_num":1000,"transaction_id":"4200000813202011189671627587","balance":"102.84","top_limit":"167.00","total_abonus":"64.16","type":0,"times":232,"create_time":1605701613,"update_time":1606992658,"reward_money":"31.00","refund_money":"31.66","finish_time":1608293613,"small_change":"0.00"},{"receives_id":2971,"user_id":15195,"account":"oYUO75fU6-NQ32LdKZqIlZwKTXzU","order_no":"2020111852991025","wxapp_id":43,"payment":"144.00","periods_num":1000,"transaction_id":"4200000818202011184038025699","balance":"82.12","top_limit":"144.00","total_abonus":"61.88","type":0,"times":229,"create_time":1605702271,"update_time":1606992658,"reward_money":"29.26","refund_money":"31.45","finish_time":1608294271,"small_change":"0.00"},{"receives_id":2972,"user_id":15121,"account":"oYUO75VKZ_nQFhpXLXO9jxrzgmgI","order_no":"2020111810056102","wxapp_id":43,"payment":"189.00","periods_num":1000,"transaction_id":"4200000821202011184856783024","balance":"128.29","top_limit":"189.00","total_abonus":"60.71","type":0,"times":228,"create_time":1605702329,"update_time":1606992658,"reward_money":"29.03","refund_money":"30.27","finish_time":1608294329,"small_change":"0.00"},{"receives_id":2978,"user_id":15203,"account":"oYUO75f4TC0GNdXn6GpUqUZIcwsg","order_no":"2020111848989851","wxapp_id":43,"payment":"288.00","periods_num":1000,"transaction_id":"4200000846202011188817626935","balance":"228.70","top_limit":"288.00","total_abonus":"59.30","type":0,"times":227,"create_time":1605703094,"update_time":1606992658,"reward_money":"28.79","refund_money":"28.52","finish_time":1608295094,"small_change":"0.00"},{"receives_id":2979,"user_id":15146,"account":"oYUO75ahUa7VfemI0cOVoTRjMlAk","order_no":"VIP2020111855102499","wxapp_id":43,"payment":"888.00","periods_num":1000,"transaction_id":"4200000843202011189121514572","balance":"830.69","top_limit":"888.00","total_abonus":"57.31","type":0,"times":226,"create_time":1605703646,"update_time":1606992658,"reward_money":"28.40","refund_money":"28.28","finish_time":1608295646,"small_change":"0.00"},{"receives_id":2981,"user_id":15206,"account":"oYUO75exFDRfjxGudZXrxQ9lBOSU","order_no":"2020111854545654","wxapp_id":43,"payment":"238.00","periods_num":1000,"transaction_id":"4200000848202011188312504889","balance":"181.39","top_limit":"238.00","total_abonus":"56.61","type":0,"times":224,"create_time":1605703804,"update_time":1606992658,"reward_money":"27.65","refund_money":"27.54","finish_time":1608295804,"small_change":"0.00"},{"receives_id":2986,"user_id":15108,"account":"oYUO75T9PmSlyXfixNy1mXeY3L1g","order_no":"2020111855505648","wxapp_id":43,"payment":"154.00","periods_num":1000,"transaction_id":"4200000812202011189475834273","balance":"98.87","top_limit":"154.00","total_abonus":"55.13","type":0,"times":222,"create_time":1605705452,"update_time":1606992658,"reward_money":"26.94","refund_money":"27.33","finish_time":1608297452,"small_change":"0.00"},{"receives_id":2987,"user_id":15215,"account":"oYUO75cY40N7oviGxAOyK_HckeNc","order_no":"2020111810148505","wxapp_id":43,"payment":"384.00","periods_num":1000,"transaction_id":"4200000820202011181461634647","balance":"329.73","top_limit":"384.00","total_abonus":"54.27","type":0,"times":221,"create_time":1605705619,"update_time":1606992658,"reward_money":"26.49","refund_money":"25.75","finish_time":1608297619,"small_change":"0.00"},{"receives_id":2993,"user_id":15221,"account":"oYUO75dysqZzWsWQSp7nHN7UvovA","order_no":"2020111810210152","wxapp_id":43,"payment":"156.00","periods_num":1000,"transaction_id":"4200000826202011189359480355","balance":"103.76","top_limit":"156.00","total_abonus":"52.24","type":0,"times":220,"create_time":1605709945,"update_time":1606992658,"reward_money":"26.21","refund_money":"25.25","finish_time":1608301945,"small_change":"0.00"},{"receives_id":2998,"user_id":15213,"account":"oYUO75YhrzNXB18ik5K1DU3suW3s","order_no":"2020111851495553","wxapp_id":43,"payment":"539.00","periods_num":1000,"transaction_id":"4200000843202011187135549168","balance":"487.54","top_limit":"539.00","total_abonus":"51.46","type":0,"times":219,"create_time":1605712792,"update_time":1606992658,"reward_money":"25.71","refund_money":"23.20","finish_time":1608304792,"small_change":"0.00"},{"receives_id":3000,"user_id":13713,"account":"oYUO75SVbpIv08xf3y8CiYBRqB-E","order_no":"2020111848519954","wxapp_id":43,"payment":"138.00","periods_num":1000,"transaction_id":"4200000825202011181089206200","balance":"89.09","top_limit":"138.00","total_abonus":"48.91","type":0,"times":218,"create_time":1605714743,"update_time":1606992658,"reward_money":"25.48","refund_money":"22.81","finish_time":1608306743,"small_change":"0.00"},{"receives_id":3001,"user_id":15214,"account":"oYUO75RZUoJJuOiElwCM9j6PZ2Xw","order_no":"VIP2020111953575748","wxapp_id":43,"payment":"888.00","periods_num":1000,"transaction_id":"4200000812202011199937338250","balance":"840.25","top_limit":"888.00","total_abonus":"47.75","type":0,"times":216,"create_time":1605717516,"update_time":1606992658,"reward_money":"24.59","refund_money":"22.74","finish_time":1608309516,"small_change":"0.00"},{"receives_id":3022,"user_id":15295,"account":"oYUO75Ru0A4JNwFz_dmZH3x-9zZQ","order_no":"2020111950545310","wxapp_id":43,"payment":"153.00","periods_num":1000,"transaction_id":"4200000814202011190329531204","balance":"105.67","top_limit":"153.00","total_abonus":"47.33","type":0,"times":215,"create_time":1605758969,"update_time":1606992658,"reward_money":"24.28","refund_money":"22.43","finish_time":1608350969,"small_change":"0.00"},{"receives_id":3037,"user_id":15335,"account":"oYUO75ZiASEuF_exEFNGpgP-daMw","order_no":"2020111951521001","wxapp_id":43,"payment":"234.00","periods_num":1000,"transaction_id":"4200000841202011195969700778","balance":"187.29","top_limit":"234.00","total_abonus":"46.71","type":0,"times":214,"create_time":1605762601,"update_time":1606992658,"reward_money":"24.01","refund_money":"21.79","finish_time":1608354601,"small_change":"0.00"},{"receives_id":3038,"user_id":15290,"account":"oYUO75fk801AnCG8JAQkzEoBAjNA","order_no":"2020111999484854","wxapp_id":43,"payment":"168.00","periods_num":1000,"transaction_id":"4200000842202011195150544226","balance":"122.20","top_limit":"168.00","total_abonus":"45.80","type":0,"times":213,"create_time":1605762722,"update_time":1606992657,"reward_money":"23.83","refund_money":"21.34","finish_time":1608354722,"small_change":"0.00"},{"receives_id":3046,"user_id":15303,"account":"oYUO75Szd4A-ZAym77ecU3tlopTA","order_no":"2020111999514848","wxapp_id":43,"payment":"556.00","periods_num":1000,"transaction_id":"4200000819202011199431517983","balance":"510.83","top_limit":"556.00","total_abonus":"45.17","type":0,"times":212,"create_time":1605765907,"update_time":1606992657,"reward_money":"23.41","refund_money":"19.76","finish_time":1608357907,"small_change":"0.00"},{"receives_id":3048,"user_id":15347,"account":"oYUO75ff8UZQC5MfpVMg3xHDKHKU","order_no":"2020111948515156","wxapp_id":43,"payment":"229.00","periods_num":1000,"transaction_id":"4200000814202011199983659822","balance":"185.83","top_limit":"229.00","total_abonus":"43.17","type":0,"times":211,"create_time":1605766516,"update_time":1606992657,"reward_money":"23.03","refund_money":"19.35","finish_time":1608358516,"small_change":"0.00"},{"receives_id":3059,"user_id":15058,"account":"oYUO75Q_qpwZvbCyDBram5vcnMrg","order_no":"2020111997521024","wxapp_id":43,"payment":"210.00","periods_num":1000,"transaction_id":"4200000824202011199337636463","balance":"167.62","top_limit":"210.00","total_abonus":"42.38","type":0,"times":210,"create_time":1605780000,"update_time":1606992657,"reward_money":"22.87","refund_money":"18.81","finish_time":1608372000,"small_change":"0.00"},{"receives_id":3063,"user_id":15418,"account":"oYUO75VRuPWDXmNkDGeDfTano-kA","order_no":"2020111951505499","wxapp_id":43,"payment":"139.00","periods_num":1000,"transaction_id":"4200000846202011197821122644","balance":"97.32","top_limit":"139.00","total_abonus":"41.68","type":0,"times":209,"create_time":1605781897,"update_time":1606992657,"reward_money":"22.37","refund_money":"18.87","finish_time":1608373897,"small_change":"0.00"},{"receives_id":3066,"user_id":15398,"account":"oYUO75QZq2DxTk7mlUOk1tS2ziFw","order_no":"2020111999535450","wxapp_id":43,"payment":"148.00","periods_num":1000,"transaction_id":"4200000821202011198748867791","balance":"106.76","top_limit":"148.00","total_abonus":"41.24","type":0,"times":208,"create_time":1605782804,"update_time":1606992657,"reward_money":"22.19","refund_money":"18.60","finish_time":1608374804,"small_change":"0.00"},{"receives_id":3071,"user_id":15430,"account":"oYUO75Xrl3UQ5xVuLPzc6uj5QsEI","order_no":"2020111949505148","wxapp_id":43,"payment":"145.00","periods_num":1000,"transaction_id":"4200000814202011190841268896","balance":"104.21","top_limit":"145.00","total_abonus":"40.79","type":0,"times":207,"create_time":1605784469,"update_time":1606992657,"reward_money":"22.02","refund_money":"18.34","finish_time":1608376469,"small_change":"0.00"},{"receives_id":3077,"user_id":15438,"account":"oYUO75Y2SVbunNgOlznW2jvWMTio","order_no":"2020111910210152","wxapp_id":43,"payment":"246.00","periods_num":1000,"transaction_id":"4200000821202011197598789763","balance":"205.64","top_limit":"246.00","total_abonus":"40.36","type":0,"times":206,"create_time":1605785038,"update_time":1606992657,"reward_money":"21.75","refund_money":"17.90","finish_time":1608377038,"small_change":"0.00"},{"receives_id":3079,"user_id":15440,"account":"oYUO75eQjKMuuLaqzHmS9kxa964U","order_no":"2020111910053501","wxapp_id":43,"payment":"155.00","periods_num":1000,"transaction_id":"4200000820202011191392639896","balance":"115.35","top_limit":"155.00","total_abonus":"39.65","type":0,"times":205,"create_time":1605785318,"update_time":1606992657,"reward_money":"21.64","refund_money":"17.58","finish_time":1608377318,"small_change":"0.00"},{"receives_id":3081,"user_id":15443,"account":"oYUO75bpzF6mQGzzmuN__lZUNGcA","order_no":"2020111954995198","wxapp_id":43,"payment":"234.00","periods_num":1000,"transaction_id":"4200000812202011198625654124","balance":"194.78","top_limit":"234.00","total_abonus":"39.22","type":0,"times":204,"create_time":1605785601,"update_time":1606992657,"reward_money":"21.45","refund_money":"17.14","finish_time":1608377601,"small_change":"0.00"},{"receives_id":3085,"user_id":15402,"account":"oYUO75a3NWY26vuJb0Lp1dnxhefA","order_no":"2020111955525757","wxapp_id":43,"payment":"148.00","periods_num":1000,"transaction_id":"4200000845202011194787989417","balance":"109.41","top_limit":"148.00","total_abonus":"38.59","type":0,"times":203,"create_time":1605786125,"update_time":1606992657,"reward_money":"21.28","refund_money":"16.92","finish_time":1608378125,"small_change":"0.00"},{"receives_id":3096,"user_id":15464,"account":"oYUO75RPhbKjYWWcUrVpn4097I98","order_no":"2020111949100985","wxapp_id":43,"payment":"212.00","periods_num":1000,"transaction_id":"4200000823202011197697514056","balance":"173.80","top_limit":"212.00","total_abonus":"38.20","type":0,"times":202,"create_time":1605787860,"update_time":1606992657,"reward_money":"21.12","refund_money":"16.54","finish_time":1608379860,"small_change":"0.00"},{"receives_id":3103,"user_id":15426,"account":"oYUO75YuNu625P8vd3Y39SEcB7mo","order_no":"2020111951529710","wxapp_id":43,"payment":"215.00","periods_num":1000,"transaction_id":"4200000841202011194360405648","balance":"177.34","top_limit":"215.00","total_abonus":"37.66","type":0,"times":201,"create_time":1605789300,"update_time":1606992657,"reward_money":"20.97","refund_money":"16.16","finish_time":1608381300,"small_change":"0.00"},{"receives_id":3110,"user_id":15471,"account":"oYUO75Z9aGb6kS11AlVALYSEjvsY","order_no":"2020111955565055","wxapp_id":43,"payment":"215.00","periods_num":1000,"transaction_id":"4200000816202011198094085182","balance":"177.87","top_limit":"215.00","total_abonus":"37.13","type":0,"times":200,"create_time":1605790637,"update_time":1606992657,"reward_money":"20.74","refund_money":"15.87","finish_time":1608382637,"small_change":"0.00"},{"receives_id":3116,"user_id":15476,"account":"oYUO75Xx7UQvR37vgAZKvud6BGfI","order_no":"2020111997515652","wxapp_id":43,"payment":"330.00","periods_num":1000,"transaction_id":"4200000822202011195337816011","balance":"293.39","top_limit":"330.00","total_abonus":"36.61","type":0,"times":199,"create_time":1605791376,"update_time":1606992657,"reward_money":"20.51","refund_money":"15.32","finish_time":1608383376,"small_change":"0.00"},{"receives_id":3126,"user_id":15409,"account":"oYUO75c7tFTN6sq6dqaPIQCUxf8Y","order_no":"2020111910254525","wxapp_id":43,"payment":"149.00","periods_num":1000,"transaction_id":"4200000844202011193096833166","balance":"113.17","top_limit":"149.00","total_abonus":"35.83","type":0,"times":198,"create_time":1605793270,"update_time":1606992657,"reward_money":"20.21","refund_money":"15.28","finish_time":1608385270,"small_change":"0.00"},{"receives_id":3127,"user_id":15486,"account":"oYUO75eLzxEf2LNEGbUpQVfoX3lE","order_no":"2020111910253554","wxapp_id":43,"payment":"340.00","periods_num":1000,"transaction_id":"4200000811202011194979319049","balance":"304.51","top_limit":"340.00","total_abonus":"35.49","type":0,"times":197,"create_time":1605793543,"update_time":1606992657,"reward_money":"19.94","refund_money":"14.79","finish_time":1608385543,"small_change":"0.00"},{"receives_id":3128,"user_id":15488,"account":"oYUO75fk6u370kEVs4wL37YqrtPI","order_no":"2020111951575454","wxapp_id":43,"payment":"184.00","periods_num":1000,"transaction_id":"4200000842202011198254564293","balance":"149.27","top_limit":"184.00","total_abonus":"34.73","type":0,"times":196,"create_time":1605793812,"update_time":1606992657,"reward_money":"19.77","refund_money":"14.56","finish_time":1608385812,"small_change":"0.00"},{"receives_id":3139,"user_id":15495,"account":"oYUO75ZrBOcxetgLKeBnDOTKUoNM","order_no":"2020111910149984","wxapp_id":43,"payment":"252.00","periods_num":1000,"transaction_id":"4200000842202011191420902615","balance":"217.67","top_limit":"252.00","total_abonus":"34.33","type":0,"times":195,"create_time":1605797509,"update_time":1606992657,"reward_money":"19.45","refund_money":"14.34","finish_time":1608389509,"small_change":"0.00"},{"receives_id":3162,"user_id":15623,"account":"oYUO75eRjSjWm9MC7zvZfhG8dSI4","order_no":"2020112049975648","wxapp_id":43,"payment":"216.00","periods_num":1000,"transaction_id":"4200000814202011206853745839","balance":"182.21","top_limit":"216.00","total_abonus":"33.79","type":0,"times":194,"create_time":1605851302,"update_time":1606992657,"reward_money":"19.35","refund_money":"13.99","finish_time":1608443302,"small_change":"0.00"},{"receives_id":3163,"user_id":15644,"account":"oYUO75f_DMIg3WRCTjCLFFxFIAmU","order_no":"2020112010256555","wxapp_id":43,"payment":"200.00","periods_num":1000,"transaction_id":"4200000815202011209600245959","balance":"166.66","top_limit":"200.00","total_abonus":"33.34","type":0,"times":193,"create_time":1605851539,"update_time":1606992657,"reward_money":"18.77","refund_money":"14.17","finish_time":1608443539,"small_change":"0.00"},{"receives_id":3171,"user_id":15661,"account":"oYUO75dvST8nMjiZV8oU3ei2M1S0","order_no":"2020112056975650","wxapp_id":43,"payment":"184.00","periods_num":1000,"transaction_id":"4200000841202011209162190398","balance":"151.06","top_limit":"184.00","total_abonus":"32.94","type":0,"times":192,"create_time":1605855616,"update_time":1606992657,"reward_money":"18.51","refund_money":"14.07","finish_time":1608447616,"small_change":"0.00"},{"receives_id":3186,"user_id":13713,"account":"oYUO75SVbpIv08xf3y8CiYBRqB-E","order_no":"2020112049511015","wxapp_id":43,"payment":"141.00","periods_num":1000,"transaction_id":"4200000824202011201864257053","balance":"108.54","top_limit":"141.00","total_abonus":"32.46","type":0,"times":190,"create_time":1605867272,"update_time":1606992657,"reward_money":"17.95","refund_money":"14.24","finish_time":1608459272,"small_change":"0.00"},{"receives_id":3189,"user_id":15720,"account":"oYUO75X3DN7qEXifQbROvSNYPUo4","order_no":"2020112050991004","wxapp_id":43,"payment":"165.00","periods_num":1000,"transaction_id":"4200000821202011204481909496","balance":"132.81","top_limit":"165.00","total_abonus":"32.19","type":0,"times":189,"create_time":1605867685,"update_time":1606992657,"reward_money":"17.76","refund_money":"14.12","finish_time":1608459685,"small_change":"0.00"},{"receives_id":3192,"user_id":13785,"account":"oYUO75ZgdC2v7xg3GuMRL_NE_bGo","order_no":"2020112056575156","wxapp_id":43,"payment":"140.00","periods_num":1000,"transaction_id":"4200000811202011204798197226","balance":"108.12","top_limit":"140.00","total_abonus":"31.88","type":0,"times":188,"create_time":1605868495,"update_time":1606992657,"reward_money":"17.61","refund_money":"14.01","finish_time":1608460495,"small_change":"0.00"},{"receives_id":3203,"user_id":15745,"account":"oYUO75T3hAR7XCjHsRzBKEAu3H2w","order_no":"2020112056515754","wxapp_id":43,"payment":"341.00","periods_num":1000,"transaction_id":"4200000821202011205874597390","balance":"309.38","top_limit":"341.00","total_abonus":"31.62","type":0,"times":187,"create_time":1605870216,"update_time":1606992657,"reward_money":"17.41","refund_money":"13.59","finish_time":1608462216,"small_change":"0.00"},{"receives_id":3204,"user_id":15710,"account":"oYUO75W9DbuNpbXi0kxG_vOCgiXE","order_no":"2020112054535651","wxapp_id":43,"payment":"263.00","periods_num":1000,"transaction_id":"4200000847202011201373057953","balance":"232.00","top_limit":"263.00","total_abonus":"31.00","type":0,"times":186,"create_time":1605870274,"update_time":1606992657,"reward_money":"17.24","refund_money":"13.29","finish_time":1608462274,"small_change":"0.00"},{"receives_id":3208,"user_id":15701,"account":"oYUO75SiwRPDmK7gELHMvhyq8uu0","order_no":"2020112057499810","wxapp_id":43,"payment":"298.00","periods_num":1000,"transaction_id":"4200000813202011205612314095","balance":"267.47","top_limit":"298.00","total_abonus":"30.53","type":0,"times":185,"create_time":1605871006,"update_time":1606992657,"reward_money":"17.09","refund_money":"12.92","finish_time":1608463006,"small_change":"0.00"},{"receives_id":3212,"user_id":15689,"account":"oYUO75c15EOs5ss8JNWwDRhNuiew","order_no":"2020112049534853","wxapp_id":43,"payment":"436.00","periods_num":1000,"transaction_id":"4200000844202011201482538606","balance":"405.99","top_limit":"436.00","total_abonus":"30.01","type":0,"times":184,"create_time":1605871822,"update_time":1606992657,"reward_money":"16.60","refund_money":"12.66","finish_time":1608463822,"small_change":"0.00"},{"receives_id":3220,"user_id":15771,"account":"oYUO75WA9G6OJHPtUhlwxi30hlLU","order_no":"2020112056975055","wxapp_id":43,"payment":"138.00","periods_num":1000,"transaction_id":"4200000814202011200868692150","balance":"108.74","top_limit":"138.00","total_abonus":"29.26","type":0,"times":183,"create_time":1605873168,"update_time":1606992657,"reward_money":"16.19","refund_money":"12.84","finish_time":1608465168,"small_change":"0.00"},{"receives_id":3228,"user_id":15782,"account":"oYUO75WQVRhhMey3GgHrIIyRt88s","order_no":"2020112099505155","wxapp_id":43,"payment":"145.00","periods_num":1000,"transaction_id":"4200000823202011203012883213","balance":"115.97","top_limit":"145.00","total_abonus":"29.03","type":0,"times":182,"create_time":1605874412,"update_time":1606992657,"reward_money":"16.10","refund_money":"12.69","finish_time":1608466412,"small_change":"0.00"},{"receives_id":3235,"user_id":15758,"account":"oYUO75XnzPdDaj9-2AurDay0B3_s","order_no":"2020112099569898","wxapp_id":43,"payment":"239.00","periods_num":1000,"transaction_id":"4200000825202011205066345826","balance":"210.21","top_limit":"239.00","total_abonus":"28.79","type":0,"times":181,"create_time":1605875747,"update_time":1606992657,"reward_money":"15.94","refund_money":"12.46","finish_time":1608467747,"small_change":"0.00"},{"receives_id":3242,"user_id":15763,"account":"oYUO75XclI1MBvg-bmMzLlLNLvys","order_no":"2020112052545451","wxapp_id":43,"payment":"332.00","periods_num":1000,"transaction_id":"4200000825202011205382963942","balance":"303.60","top_limit":"332.00","total_abonus":"28.40","type":0,"times":180,"create_time":1605876922,"update_time":1606992657,"reward_money":"15.77","refund_money":"12.10","finish_time":1608468922,"small_change":"0.00"},{"receives_id":3243,"user_id":15807,"account":"oYUO75SFz2tpT213wTDs0AH1kyQg","order_no":"2020112050565354","wxapp_id":43,"payment":"141.00","periods_num":1000,"transaction_id":"4200000811202011203230470515","balance":"113.13","top_limit":"141.00","total_abonus":"27.87","type":0,"times":179,"create_time":1605877080,"update_time":1606992657,"reward_money":"15.56","refund_money":"12.09","finish_time":1608469080,"small_change":"0.00"},{"receives_id":3245,"user_id":15808,"account":"oYUO75Z-j_WqB--t7DlPBIVTp5yY","order_no":"2020112048535110","wxapp_id":43,"payment":"326.00","periods_num":1000,"transaction_id":"4200000813202011206301956153","balance":"298.35","top_limit":"326.00","total_abonus":"27.65","type":0,"times":178,"create_time":1605877246,"update_time":1606992657,"reward_money":"15.28","refund_money":"11.87","finish_time":1608469246,"small_change":"0.00"},{"receives_id":3249,"user_id":15791,"account":"oYUO75cyDhTACiOozSWfdLPUDBR0","order_no":"2020112048489810","wxapp_id":43,"payment":"139.00","periods_num":1000,"transaction_id":"4200000821202011201645527915","balance":"111.85","top_limit":"139.00","total_abonus":"27.15","type":0,"times":177,"create_time":1605877761,"update_time":1606992657,"reward_money":"15.13","refund_money":"11.81","finish_time":1608469761,"small_change":"0.00"},{"receives_id":3256,"user_id":15768,"account":"oYUO75TXVceq7xKIzKZcVYA46bWA","order_no":"2020112049100101","wxapp_id":43,"payment":"304.00","periods_num":1000,"transaction_id":"4200000821202011209085888284","balance":"277.06","top_limit":"304.00","total_abonus":"26.94","type":0,"times":176,"create_time":1605879463,"update_time":1606992657,"reward_money":"14.99","refund_money":"11.50","finish_time":1608471463,"small_change":"0.00"},{"receives_id":3257,"user_id":15819,"account":"oYUO75ei1XSjp3qWmHi0UFSb_FaA","order_no":"2020112010051999","wxapp_id":43,"payment":"190.00","periods_num":1000,"transaction_id":"4200000820202011205217748034","balance":"163.51","top_limit":"190.00","total_abonus":"26.49","type":0,"times":175,"create_time":1605879506,"update_time":1606992657,"reward_money":"14.80","refund_money":"11.41","finish_time":1608471506,"small_change":"0.00"},{"receives_id":3260,"user_id":15487,"account":"oYUO75dQ7h_vAYsVnL4LFayvBlbs","order_no":"2020112049565697","wxapp_id":43,"payment":"351.00","periods_num":1000,"transaction_id":"4200000816202011206953960239","balance":"324.79","top_limit":"351.00","total_abonus":"26.21","type":0,"times":174,"create_time":1605880057,"update_time":1606992657,"reward_money":"14.62","refund_money":"11.09","finish_time":1608472057,"small_change":"0.00"},{"receives_id":3261,"user_id":15822,"account":"oYUO75WLwR14RJMVWX6fOTAj9BKA","order_no":"2020112052102515","wxapp_id":43,"payment":"165.00","periods_num":1000,"transaction_id":"4200000827202011203567865849","balance":"139.29","top_limit":"165.00","total_abonus":"25.71","type":0,"times":173,"create_time":1605880123,"update_time":1606992657,"reward_money":"14.50","refund_money":"10.98","finish_time":1608472123,"small_change":"0.00"},{"receives_id":3263,"user_id":15784,"account":"oYUO75QPXoJtFUECf1oTuVS0pSiE","order_no":"2020112010057521","wxapp_id":43,"payment":"356.00","periods_num":1000,"transaction_id":"4200000821202011208574031090","balance":"330.52","top_limit":"356.00","total_abonus":"25.48","type":0,"times":172,"create_time":1605880536,"update_time":1606992657,"reward_money":"14.38","refund_money":"10.60","finish_time":1608472536,"small_change":"0.00"},{"receives_id":3264,"user_id":15825,"account":"oYUO75eFABMOjww36lEUHgXWPPa4","order_no":"2020112052509710","wxapp_id":43,"payment":"283.00","periods_num":1000,"transaction_id":"4200000818202011201057041655","balance":"258.02","top_limit":"283.00","total_abonus":"24.98","type":0,"times":171,"create_time":1605880605,"update_time":1606992657,"reward_money":"14.25","refund_money":"10.34","finish_time":1608472605,"small_change":"0.00"},{"receives_id":3267,"user_id":15829,"account":"oYUO75YNNGDCGCvHVErwfZltIg9U","order_no":"2020112057100545","wxapp_id":43,"payment":"231.00","periods_num":1000,"transaction_id":"4200000820202011209661412973","balance":"206.41","top_limit":"231.00","total_abonus":"24.59","type":0,"times":170,"create_time":1605881495,"update_time":1606992657,"reward_money":"14.11","refund_money":"10.17","finish_time":1608473495,"small_change":"0.00"},{"receives_id":3268,"user_id":15830,"account":"oYUO75TXpsT9rQ-ChDebXZKpITHI","order_no":"2020112048525454","wxapp_id":43,"payment":"201.00","periods_num":1000,"transaction_id":"4200000846202011204917576023","balance":"176.72","top_limit":"201.00","total_abonus":"24.28","type":0,"times":169,"create_time":1605881718,"update_time":1606992656,"reward_money":"13.94","refund_money":"10.07","finish_time":1608473718,"small_change":"0.00"},{"receives_id":3271,"user_id":15834,"account":"oYUO75SDwfiPSQasWbElY-Mjhmu4","order_no":"2020112010210110","wxapp_id":43,"payment":"140.00","periods_num":1000,"transaction_id":"4200000847202011209494644942","balance":"115.99","top_limit":"140.00","total_abonus":"24.01","type":0,"times":168,"create_time":1605882491,"update_time":1606992656,"reward_money":"13.79","refund_money":"10.04","finish_time":1608474491,"small_change":"0.00"},{"receives_id":3272,"user_id":15820,"account":"oYUO75erzDJ--c1aPm4y7v6az7-E","order_no":"2020112010199975","wxapp_id":43,"payment":"327.00","periods_num":1000,"transaction_id":"4200000815202011203720170907","balance":"303.17","top_limit":"327.00","total_abonus":"23.83","type":0,"times":167,"create_time":1605882627,"update_time":1606992656,"reward_money":"13.55","refund_money":"9.86","finish_time":1608474627,"small_change":"0.00"},{"receives_id":3274,"user_id":15836,"account":"oYUO75cj-B0EtOcWfhSZMMSttGf8","order_no":"2020112053495454","wxapp_id":43,"payment":"298.00","periods_num":1000,"transaction_id":"4200000821202011201717338383","balance":"274.59","top_limit":"298.00","total_abonus":"23.41","type":0,"times":166,"create_time":1605884814,"update_time":1606992656,"reward_money":"13.38","refund_money":"9.65","finish_time":1608476814,"small_change":"0.00"},{"receives_id":3275,"user_id":15755,"account":"oYUO75YCJ8lcIQimZbYO3RFL3c2Q","order_no":"2020112098509710","wxapp_id":43,"payment":"399.00","periods_num":1000,"transaction_id":"4200000841202011200316161689","balance":"376.13","top_limit":"399.00","total_abonus":"22.87","type":0,"times":164,"create_time":1605887728,"update_time":1606992656,"reward_money":"13.06","refund_money":"9.31","finish_time":1608479728,"small_change":"0.00"},{"receives_id":3276,"user_id":15833,"account":"oYUO75TlOTZ24KdRAn-IxLvcEwvA","order_no":"2020112155535750","wxapp_id":43,"payment":"150.00","periods_num":1000,"transaction_id":"4200000823202011214660100585","balance":"127.63","top_limit":"150.00","total_abonus":"22.37","type":0,"times":163,"create_time":1605890157,"update_time":1606992656,"reward_money":"12.94","refund_money":"9.25","finish_time":1608482157,"small_change":"0.00"},{"receives_id":3284,"user_id":15849,"account":"oYUO75SmI36lTg5TgurOcsOxlwoM","order_no":"2020112148495748","wxapp_id":43,"payment":"138.00","periods_num":1000,"transaction_id":"4200000827202011214587877384","balance":"115.81","top_limit":"138.00","total_abonus":"22.19","type":0,"times":162,"create_time":1605930135,"update_time":1606992656,"reward_money":"12.79","refund_money":"9.23","finish_time":1608522135,"small_change":"0.00"},{"receives_id":3294,"user_id":15874,"account":"oYUO75aAGBf0u33dsG400bQCA9hg","order_no":"2020112198555352","wxapp_id":43,"payment":"224.00","periods_num":1000,"transaction_id":"4200000825202011219220948208","balance":"201.98","top_limit":"224.00","total_abonus":"22.02","type":0,"times":161,"create_time":1605935736,"update_time":1606992656,"reward_money":"12.69","refund_money":"9.06","finish_time":1608527736,"small_change":"0.00"},{"receives_id":3298,"user_id":15881,"account":"oYUO75Qn7XBu5xxTaAq18CtdUCrU","order_no":"2020112151494948","wxapp_id":43,"payment":"163.00","periods_num":1000,"transaction_id":"4200000844202011216651203885","balance":"141.36","top_limit":"163.00","total_abonus":"21.64","type":0,"times":159,"create_time":1605937833,"update_time":1606992656,"reward_money":"12.31","refund_money":"9.14","finish_time":1608529833,"small_change":"0.00"},{"receives_id":3299,"user_id":15882,"account":"oYUO75XLbjfi52s-XVvBRBzTioSM","order_no":"2020112150525150","wxapp_id":43,"payment":"144.00","periods_num":1000,"transaction_id":"4200000814202011219511904940","balance":"122.55","top_limit":"144.00","total_abonus":"21.45","type":0,"times":158,"create_time":1605938059,"update_time":1606992656,"reward_money":"12.20","refund_money":"9.08","finish_time":1608530059,"small_change":"0.00"},{"receives_id":3300,"user_id":15883,"account":"oYUO75eA0g3qV-hcJq3kJlUbB22w","order_no":"2020112156101995","wxapp_id":43,"payment":"139.00","periods_num":1000,"transaction_id":"4200000842202011218395512300","balance":"117.72","top_limit":"139.00","total_abonus":"21.28","type":0,"times":157,"create_time":1605938149,"update_time":1606992656,"reward_money":"12.07","refund_money":"9.05","finish_time":1608530149,"small_change":"0.00"},{"receives_id":3306,"user_id":15897,"account":"oYUO75f4ZqbP6_BHJ-4-APq2_CoA","order_no":"2020112197555299","wxapp_id":43,"payment":"138.00","periods_num":1000,"transaction_id":"4200000819202011212000321889","balance":"116.88","top_limit":"138.00","total_abonus":"21.12","type":0,"times":156,"create_time":1605943136,"update_time":1606992656,"reward_money":"11.95","refund_money":"9.02","finish_time":1608535136,"small_change":"0.00"},{"receives_id":3319,"user_id":15904,"account":"oYUO75RtJUB94jxYrshtK2M7mMVM","order_no":"2020112150511001","wxapp_id":43,"payment":"209.00","periods_num":1000,"transaction_id":"4200000841202011213863503042","balance":"188.03","top_limit":"209.00","total_abonus":"20.97","type":0,"times":155,"create_time":1605948902,"update_time":1606992656,"reward_money":"11.85","refund_money":"8.89","finish_time":1608540902,"small_change":"0.00"}]';
        $arr = json_decode($jsarr,true);
     //   pre($arr);

        foreach ($arr as $key=>$value){
            $extends=db('divide_receives_user')->where('receives_id',$value['receives_id'])->value('extend');

            $data = json_decode($extends, true);
            if(count($data)>1){
                //把查询出来的数据转成数据

                //获取最后一个数组
//                $lastData=end($data);
             //   $this->log('最后一个数组',$lastData);
                //存在的话，把最后一个数组删除
                 array_pop( $data);
                 $res = json_encode($data);
                 db('divide_receives_user')->where('receives_id',$value['receives_id'])->setField('extend',$res);
            }
        }

    }


    public function dson2(){
        $params=$this->request->param();
//        $dataList=db('divide_receives')->where(['wxapp_id'=>$params['id'],'periods_num'=>$params['num'],'type'=>0])->field('receives_id')->order('receives_id asc')->select();
//        $this->log('分账用户',$dataList);
        $jsarr1='[{"receives_id":3320,"user_id":15906,"account":"oYUO75U8WSAD3gzNAToJvBON-cz4","order_no":"2020112110055545","wxapp_id":43,"payment":"212.00","periods_num":1000,"transaction_id":"4200000809202011211948534082","balance":"191.26","top_limit":"212.00","total_abonus":"20.74","type":0,"times":154,"create_time":1605949011,"update_time":1606992656,"reward_money":"11.83","refund_money":"8.68","finish_time":1608541011,"small_change":"0.00"},{"receives_id":3322,"user_id":15908,"account":"oYUO75ayrLP9M5rVDmJAN7C1itJE","order_no":"2020112197561005","wxapp_id":43,"payment":"272.00","periods_num":1000,"transaction_id":"4200000822202011213105411695","balance":"251.49","top_limit":"272.00","total_abonus":"20.51","type":0,"times":153,"create_time":1605950193,"update_time":1606992656,"reward_money":"11.72","refund_money":"8.49","finish_time":1608542193,"small_change":"0.00"},{"receives_id":3330,"user_id":15928,"account":"oYUO75QwkHWN8CCIezwLvX-hD07E","order_no":"2020112110056101","wxapp_id":43,"payment":"246.00","periods_num":1000,"transaction_id":"4200000826202011212750101678","balance":"225.79","top_limit":"246.00","total_abonus":"20.21","type":0,"times":152,"create_time":1605954791,"update_time":1606992656,"reward_money":"11.45","refund_money":"8.49","finish_time":1608546791,"small_change":"0.00"},{"receives_id":3331,"user_id":15929,"account":"oYUO75a_e7WI28-XRER-PrHKEXV8","order_no":"2020112110151102","wxapp_id":43,"payment":"163.00","periods_num":1000,"transaction_id":"4200000842202011218100240572","balance":"143.06","top_limit":"163.00","total_abonus":"19.94","type":0,"times":151,"create_time":1605954995,"update_time":1606992656,"reward_money":"11.35","refund_money":"8.42","finish_time":1608546995,"small_change":"0.00"},{"receives_id":3343,"user_id":15939,"account":"oYUO75bnxUPlh7KJbdglwt9qJ2tI","order_no":"2020112156505710","wxapp_id":43,"payment":"305.00","periods_num":1000,"transaction_id":"4200000821202011215461207018","balance":"285.23","top_limit":"305.00","total_abonus":"19.77","type":0,"times":150,"create_time":1605957469,"update_time":1606992656,"reward_money":"11.26","refund_money":"8.19","finish_time":1608549469,"small_change":"0.00"},{"receives_id":3351,"user_id":15946,"account":"oYUO75crcs06KUsaEZ68vIyk7khk","order_no":"VIP2020112155575050","wxapp_id":43,"payment":"888.00","periods_num":1000,"transaction_id":"4200000812202011212911962540","balance":"868.55","top_limit":"888.00","total_abonus":"19.45","type":0,"times":149,"create_time":1605958621,"update_time":1606992656,"reward_money":"11.12","refund_money":"8.23","finish_time":1608550621,"small_change":"0.00"},{"receives_id":3355,"user_id":15919,"account":"oYUO75c0XqNM9_23gN4bjfj6aPk0","order_no":"2020112148574950","wxapp_id":43,"payment":"558.00","periods_num":1000,"transaction_id":"4200000825202011214348547152","balance":"538.65","top_limit":"558.00","total_abonus":"19.35","type":0,"times":148,"create_time":1605959062,"update_time":1606992656,"reward_money":"10.97","refund_money":"7.80","finish_time":1608551062,"small_change":"0.00"},{"receives_id":3356,"user_id":15950,"account":"oYUO75dI2ruDdLBhX5nliEscrWGY","order_no":"2020112197984950","wxapp_id":43,"payment":"256.00","periods_num":1000,"transaction_id":"4200000844202011212003310925","balance":"237.23","top_limit":"256.00","total_abonus":"18.77","type":0,"times":147,"create_time":1605959137,"update_time":1606992656,"reward_money":"10.86","refund_money":"7.65","finish_time":1608551137,"small_change":"0.00"},{"receives_id":3357,"user_id":15951,"account":"oYUO75bAMUopEcHjBxjEZcexI82k","order_no":"2020112154525148","wxapp_id":43,"payment":"221.00","periods_num":1000,"transaction_id":"4200000809202011217660818481","balance":"202.49","top_limit":"221.00","total_abonus":"18.51","type":0,"times":146,"create_time":1605959245,"update_time":1606992656,"reward_money":"10.58","refund_money":"7.71","finish_time":1608551245,"small_change":"0.00"},{"receives_id":3367,"user_id":15963,"account":"oYUO75UtCB792s3mFYQbIr23gJFI","order_no":"2020112152499910","wxapp_id":43,"payment":"341.00","periods_num":1000,"transaction_id":"4200000828202011217922323854","balance":"322.71","top_limit":"341.00","total_abonus":"18.29","type":0,"times":145,"create_time":1605960585,"update_time":1606992656,"reward_money":"10.52","refund_money":"7.43","finish_time":1608552585,"small_change":"0.00"},{"receives_id":3368,"user_id":15964,"account":"oYUO75SSWubnf1Xg2GFGFZ4PMryQ","order_no":"2020112110253561","wxapp_id":43,"payment":"191.00","periods_num":1000,"transaction_id":"4200000824202011215971459693","balance":"173.05","top_limit":"191.00","total_abonus":"17.95","type":0,"times":144,"create_time":1605960643,"update_time":1606992656,"reward_money":"10.43","refund_money":"7.33","finish_time":1608552643,"small_change":"0.00"},{"receives_id":3371,"user_id":15967,"account":"oYUO75TLdRVWODPd2CkePsDmrum4","order_no":"2020112110053569","wxapp_id":43,"payment":"158.00","periods_num":1000,"transaction_id":"4200000825202011213907389729","balance":"140.24","top_limit":"158.00","total_abonus":"17.76","type":0,"times":143,"create_time":1605961194,"update_time":1606992656,"reward_money":"10.27","refund_money":"7.34","finish_time":1608553194,"small_change":"0.00"},{"receives_id":3378,"user_id":15973,"account":"oYUO75TtPXXr_QUlhbxsEqa4Bn30","order_no":"2020112156101521","wxapp_id":43,"payment":"207.00","periods_num":1000,"transaction_id":"4200000844202011219741064898","balance":"189.39","top_limit":"207.00","total_abonus":"17.61","type":0,"times":142,"create_time":1605961825,"update_time":1606992656,"reward_money":"10.18","refund_money":"7.23","finish_time":1608553825,"small_change":"0.00"},{"receives_id":3379,"user_id":15974,"account":"oYUO75Xm4hWG-KzmdQGIYiKb4oAs","order_no":"2020112198524910","wxapp_id":43,"payment":"176.00","periods_num":1000,"transaction_id":"4200000847202011217394170165","balance":"158.59","top_limit":"176.00","total_abonus":"17.41","type":0,"times":141,"create_time":1605962082,"update_time":1606992656,"reward_money":"9.94","refund_money":"7.30","finish_time":1608554082,"small_change":"0.00"},{"receives_id":3388,"user_id":15980,"account":"oYUO75ahooWKJ7dgKWuMHAQFyJv8","order_no":"2020112150559999","wxapp_id":43,"payment":"166.00","periods_num":1000,"transaction_id":"4200000818202011216253024839","balance":"148.76","top_limit":"166.00","total_abonus":"17.24","type":0,"times":140,"create_time":1605963003,"update_time":1606992656,"reward_money":"9.85","refund_money":"7.24","finish_time":1608555003,"small_change":"0.00"},{"receives_id":3390,"user_id":15982,"account":"oYUO75bOiYk6bLFMxkfpDJ2UI0TE","order_no":"2020112156485451","wxapp_id":43,"payment":"520.00","periods_num":1000,"transaction_id":"4200000842202011218959103297","balance":"502.91","top_limit":"520.00","total_abonus":"17.09","type":0,"times":139,"create_time":1605963791,"update_time":1606992656,"reward_money":"9.72","refund_money":"6.88","finish_time":1608555791,"small_change":"0.00"},{"receives_id":3394,"user_id":15985,"account":"oYUO75Sb25fGEx4cSvHnNvOQerWw","order_no":"2020112150545454","wxapp_id":43,"payment":"446.00","periods_num":1000,"transaction_id":"4200000811202011216396215810","balance":"429.40","top_limit":"446.00","total_abonus":"16.60","type":0,"times":138,"create_time":1605964392,"update_time":1606992656,"reward_money":"9.66","refund_money":"6.53","finish_time":1608556392,"small_change":"0.00"},{"receives_id":3397,"user_id":15988,"account":"oYUO75UyR18pADAMo_o_Ysx9cJDc","order_no":"VIP2020112148991015","wxapp_id":43,"payment":"888.00","periods_num":1000,"transaction_id":"4200000819202011212374879182","balance":"871.81","top_limit":"888.00","total_abonus":"16.19","type":0,"times":137,"create_time":1605964889,"update_time":1606992656,"reward_money":"9.55","refund_money":"6.55","finish_time":1608556889,"small_change":"0.00"},{"receives_id":3398,"user_id":15954,"account":"oYUO75RuRbtSq5s1BmWST5N8ZQTA","order_no":"2020112151505310","wxapp_id":43,"payment":"177.00","periods_num":1000,"transaction_id":"4200000811202011213998626429","balance":"160.90","top_limit":"177.00","total_abonus":"16.10","type":0,"times":136,"create_time":1605965471,"update_time":1606992656,"reward_money":"9.42","refund_money":"6.52","finish_time":1608557471,"small_change":"0.00"},{"receives_id":3401,"user_id":15962,"account":"oYUO75Ue8bYhrCDSaoXT4UP9IFY0","order_no":"2020112149100551","wxapp_id":43,"payment":"192.00","periods_num":1000,"transaction_id":"4200000814202011215100878202","balance":"176.06","top_limit":"192.00","total_abonus":"15.94","type":0,"times":135,"create_time":1605966232,"update_time":1606992656,"reward_money":"9.31","refund_money":"6.46","finish_time":1608558232,"small_change":"0.00"},{"receives_id":3402,"user_id":15992,"account":"oYUO75TKNnw1LaUKr961bNwg3RQs","order_no":"2020112199100509","wxapp_id":43,"payment":"235.00","periods_num":1000,"transaction_id":"4200000819202011211654478659","balance":"219.23","top_limit":"235.00","total_abonus":"15.77","type":0,"times":134,"create_time":1605966595,"update_time":1606992656,"reward_money":"9.22","refund_money":"6.34","finish_time":1608558595,"small_change":"0.00"},{"receives_id":3403,"user_id":15995,"account":"oYUO75bZ711gV6rVYP5XyQ5ow5qE","order_no":"2020112198985010","wxapp_id":43,"payment":"316.00","periods_num":1000,"transaction_id":"4200000820202011212247424494","balance":"300.44","top_limit":"316.00","total_abonus":"15.56","type":0,"times":133,"create_time":1605966788,"update_time":1606992656,"reward_money":"9.07","refund_money":"6.21","finish_time":1608558788,"small_change":"0.00"},{"receives_id":3407,"user_id":15999,"account":"oYUO75WXRKZO11_CztRkst8KZ3qI","order_no":"2020112156515651","wxapp_id":43,"payment":"179.00","periods_num":1000,"transaction_id":"4200000825202011215246376070","balance":"163.72","top_limit":"179.00","total_abonus":"15.28","type":0,"times":132,"create_time":1605967853,"update_time":1606992656,"reward_money":"8.96","refund_money":"6.17","finish_time":1608559853,"small_change":"0.00"},{"receives_id":3412,"user_id":15755,"account":"oYUO75YCJ8lcIQimZbYO3RFL3c2Q","order_no":"2020112152984950","wxapp_id":43,"payment":"166.00","periods_num":1000,"transaction_id":"4200000825202011210739258416","balance":"150.87","top_limit":"166.00","total_abonus":"15.13","type":0,"times":131,"create_time":1605969033,"update_time":1606992656,"reward_money":"8.80","refund_money":"6.19","finish_time":1608561033,"small_change":"0.00"},{"receives_id":3414,"user_id":13713,"account":"oYUO75SVbpIv08xf3y8CiYBRqB-E","order_no":"2020112199511004","wxapp_id":43,"payment":"222.00","periods_num":1000,"transaction_id":"4200000826202011218521948721","balance":"207.01","top_limit":"222.00","total_abonus":"14.99","type":0,"times":130,"create_time":1605969770,"update_time":1606992656,"reward_money":"8.71","refund_money":"6.09","finish_time":1608561770,"small_change":"0.00"},{"receives_id":3417,"user_id":15195,"account":"oYUO75fU6-NQ32LdKZqIlZwKTXzU","order_no":"2020112157984810","wxapp_id":43,"payment":"217.00","periods_num":1000,"transaction_id":"4200000842202011214063670232","balance":"202.20","top_limit":"217.00","total_abonus":"14.80","type":0,"times":129,"create_time":1605973680,"update_time":1606992656,"reward_money":"8.62","refund_money":"6.00","finish_time":1608565680,"small_change":"0.00"},{"receives_id":3426,"user_id":16075,"account":"oYUO75Xr-QIPp42TckrR8n8UAjYk","order_no":"2020112210252485","wxapp_id":43,"payment":"145.00","periods_num":1000,"transaction_id":"4200000818202011223918869825","balance":"130.38","top_limit":"145.00","total_abonus":"14.62","type":0,"times":128,"create_time":1606017765,"update_time":1606992656,"reward_money":"8.51","refund_money":"5.99","finish_time":1608609765,"small_change":"0.00"},{"receives_id":3427,"user_id":16085,"account":"oYUO75ZPndicGH6BNfhazfzjXqRI","order_no":"2020112249535798","wxapp_id":43,"payment":"144.00","periods_num":1000,"transaction_id":"4200000818202011222770696097","balance":"129.50","top_limit":"144.00","total_abonus":"14.50","type":0,"times":127,"create_time":1606019880,"update_time":1606992656,"reward_money":"8.30","refund_money":"6.08","finish_time":1608611880,"small_change":"0.00"},{"receives_id":3428,"user_id":16086,"account":"oYUO75bxwDkiwgs07nnuP0zEB6iA","order_no":"2020112254575199","wxapp_id":43,"payment":"157.00","periods_num":1000,"transaction_id":"4200000818202011220352556648","balance":"142.62","top_limit":"157.00","total_abonus":"14.38","type":0,"times":126,"create_time":1606020001,"update_time":1606992656,"reward_money":"8.22","refund_money":"6.03","finish_time":1608612001,"small_change":"0.00"},{"receives_id":3434,"user_id":16080,"account":"oYUO75XsqHv7XZTZkFfyF_ggEfa0","order_no":"2020112249102485","wxapp_id":43,"payment":"177.00","periods_num":1000,"transaction_id":"4200000827202011220039601709","balance":"162.75","top_limit":"177.00","total_abonus":"14.25","type":0,"times":125,"create_time":1606022023,"update_time":1606992655,"reward_money":"8.09","refund_money":"6.02","finish_time":1608614023,"small_change":"0.00"},{"receives_id":3437,"user_id":16102,"account":"oYUO75cPRNxLKtxLyHvSoJOMZo-o","order_no":"2020112256974953","wxapp_id":43,"payment":"210.00","periods_num":1000,"transaction_id":"4200000813202011227694777176","balance":"195.89","top_limit":"210.00","total_abonus":"14.11","type":0,"times":124,"create_time":1606022483,"update_time":1606992655,"reward_money":"7.87","refund_money":"6.07","finish_time":1608614483,"small_change":"0.00"},{"receives_id":3440,"user_id":16106,"account":"oYUO75bS1WIQkZL5pYTC1XJL4fTo","order_no":"2020112255971029","wxapp_id":43,"payment":"190.00","periods_num":1000,"transaction_id":"4200000846202011223657131955","balance":"176.06","top_limit":"190.00","total_abonus":"13.94","type":0,"times":123,"create_time":1606023039,"update_time":1606992655,"reward_money":"7.78","refund_money":"6.01","finish_time":1608615039,"small_change":"0.00"},{"receives_id":3443,"user_id":16111,"account":"oYUO75QKSXVxhKlbQU1Q9QIzWKt8","order_no":"2020112255504810","wxapp_id":43,"payment":"307.00","periods_num":1000,"transaction_id":"4200000820202011225678095480","balance":"293.21","top_limit":"307.00","total_abonus":"13.79","type":0,"times":122,"create_time":1606024274,"update_time":1606992655,"reward_money":"7.68","refund_money":"5.87","finish_time":1608616274,"small_change":"0.00"},{"receives_id":3444,"user_id":16112,"account":"oYUO75fVmYSVNdQGCujCIf1A_tRc","order_no":"2020112299535457","wxapp_id":43,"payment":"217.00","periods_num":1000,"transaction_id":"4200000846202011223095081355","balance":"203.45","top_limit":"217.00","total_abonus":"13.55","type":0,"times":121,"create_time":1606024629,"update_time":1606992655,"reward_money":"7.66","refund_money":"5.72","finish_time":1608616629,"small_change":"0.00"},{"receives_id":3448,"user_id":16118,"account":"oYUO75fc_WXxg7_f0hqPlL6ywRQA","order_no":"2020112251544956","wxapp_id":43,"payment":"173.00","periods_num":1000,"transaction_id":"4200000821202011227529272303","balance":"159.62","top_limit":"173.00","total_abonus":"13.38","type":0,"times":120,"create_time":1606026448,"update_time":1606992655,"reward_money":"7.61","refund_money":"5.64","finish_time":1608618448,"small_change":"0.00"},{"receives_id":3449,"user_id":16109,"account":"oYUO75a8Zb-TSihrwgQpq6qKNx98","order_no":"2020112250549798","wxapp_id":43,"payment":"249.00","periods_num":1000,"transaction_id":"4200000844202011220097896963","balance":"235.75","top_limit":"249.00","total_abonus":"13.25","type":0,"times":119,"create_time":1606026710,"update_time":1606992655,"reward_money":"7.46","refund_money":"5.60","finish_time":1608618710,"small_change":"0.00"},{"receives_id":3452,"user_id":16123,"account":"oYUO75SgS8K7yfodlDeT8UYuqGBU","order_no":"2020112250519752","wxapp_id":43,"payment":"156.00","periods_num":1000,"transaction_id":"4200000845202011222801867435","balance":"142.94","top_limit":"156.00","total_abonus":"13.06","type":0,"times":118,"create_time":1606029160,"update_time":1606992655,"reward_money":"7.36","refund_money":"5.58","finish_time":1608621160,"small_change":"0.00"},{"receives_id":3456,"user_id":16128,"account":"oYUO75ZGSTYMrjZT6uz-r3JDS70k","order_no":"2020112251101984","wxapp_id":43,"payment":"207.00","periods_num":1000,"transaction_id":"4200000817202011221424165332","balance":"194.06","top_limit":"207.00","total_abonus":"12.94","type":0,"times":117,"create_time":1606031833,"update_time":1606992655,"reward_money":"7.23","refund_money":"5.56","finish_time":1608623833,"small_change":"0.00"},{"receives_id":3457,"user_id":16129,"account":"oYUO75X5ffhJQNOHoWU3FyXeA7OI","order_no":"2020112210110251","wxapp_id":43,"payment":"144.00","periods_num":1000,"transaction_id":"4200000818202011224429247446","balance":"131.21","top_limit":"144.00","total_abonus":"12.79","type":0,"times":116,"create_time":1606032675,"update_time":1606992655,"reward_money":"7.10","refund_money":"5.59","finish_time":1608624675,"small_change":"0.00"},{"receives_id":3471,"user_id":16145,"account":"oYUO75V2JRHcEt_jk_ZbGbBz0VrQ","order_no":"2020112254989897","wxapp_id":43,"payment":"252.00","periods_num":1000,"transaction_id":"4200000812202011227477299108","balance":"239.31","top_limit":"252.00","total_abonus":"12.69","type":0,"times":115,"create_time":1606039470,"update_time":1606992655,"reward_money":"6.91","refund_money":"5.59","finish_time":1608631470,"small_change":"0.00"},{"receives_id":3472,"user_id":16138,"account":"oYUO75dhIIMaibCWdsboRBAEtYkk","order_no":"2020112257521005","wxapp_id":43,"payment":"262.00","periods_num":1000,"transaction_id":"4200000820202011220098498175","balance":"249.50","top_limit":"262.00","total_abonus":"12.50","type":0,"times":114,"create_time":1606040174,"update_time":1606992655,"reward_money":"6.74","refund_money":"5.57","finish_time":1608632174,"small_change":"0.00"},{"receives_id":3477,"user_id":16151,"account":"oYUO75bMi7-vUr9RcdYVfQc8OdWM","order_no":"2020112256525656","wxapp_id":43,"payment":"161.00","periods_num":1000,"transaction_id":"4200000812202011224734284377","balance":"148.69","top_limit":"161.00","total_abonus":"12.31","type":0,"times":113,"create_time":1606041792,"update_time":1606992655,"reward_money":"6.65","refund_money":"5.55","finish_time":1608633792,"small_change":"0.00"},{"receives_id":3479,"user_id":16152,"account":"oYUO75WCgUoADfqSZw8-nLOHRKkU","order_no":"2020112254519753","wxapp_id":43,"payment":"180.00","periods_num":1000,"transaction_id":"4200000848202011221311846161","balance":"167.80","top_limit":"180.00","total_abonus":"12.20","type":0,"times":112,"create_time":1606042220,"update_time":1606992655,"reward_money":"6.55","refund_money":"5.52","finish_time":1608634220,"small_change":"0.00"},{"receives_id":3497,"user_id":16141,"account":"oYUO75VHLXlXzgbilTWQxO00yNuY","order_no":"2020112210157101","wxapp_id":43,"payment":"176.00","periods_num":1000,"transaction_id":"4200000816202011220300161006","balance":"163.93","top_limit":"176.00","total_abonus":"12.07","type":0,"times":111,"create_time":1606045265,"update_time":1606992655,"reward_money":"6.48","refund_money":"5.47","finish_time":1608637265,"small_change":"0.00"},{"receives_id":3498,"user_id":16172,"account":"oYUO75aPBmOm45r9foxNHOF4ZkcU","order_no":"2020112253555410","wxapp_id":43,"payment":"145.00","periods_num":1000,"transaction_id":"4200000845202011225558602062","balance":"133.05","top_limit":"145.00","total_abonus":"11.95","type":0,"times":110,"create_time":1606045314,"update_time":1606992655,"reward_money":"6.37","refund_money":"5.48","finish_time":1608637314,"small_change":"0.00"},{"receives_id":3516,"user_id":16192,"account":"oYUO75bZKq-aiN3t-LAggYyM_zTM","order_no":"2020112253481021","wxapp_id":43,"payment":"157.00","periods_num":1000,"transaction_id":"4200000818202011229418514950","balance":"145.17","top_limit":"157.00","total_abonus":"11.83","type":0,"times":108,"create_time":1606048893,"update_time":1606992655,"reward_money":"6.09","refund_money":"5.63","finish_time":1608640893,"small_change":"0.00"},{"receives_id":3524,"user_id":16154,"account":"oYUO75TUcZ_tiHoS15r7SrGctSvA","order_no":"2020112251995648","wxapp_id":43,"payment":"383.00","periods_num":1000,"transaction_id":"4200000811202011224733684936","balance":"371.28","top_limit":"383.00","total_abonus":"11.72","type":0,"times":107,"create_time":1606049673,"update_time":1606992655,"reward_money":"6.04","refund_money":"5.41","finish_time":1608641673,"small_change":"0.00"},{"receives_id":3526,"user_id":16203,"account":"oYUO75XvsTagC9ybgR3LBvnoYkfs","order_no":"2020112249101101","wxapp_id":43,"payment":"149.00","periods_num":1000,"transaction_id":"4200000822202011224100360743","balance":"137.55","top_limit":"149.00","total_abonus":"11.45","type":0,"times":106,"create_time":1606049881,"update_time":1606992655,"reward_money":"5.95","refund_money":"5.40","finish_time":1608641881,"small_change":"0.00"},{"receives_id":3527,"user_id":16204,"account":"oYUO75SPB5F67Wb6OPx6NIRyYv-E","order_no":"2020112253100569","wxapp_id":43,"payment":"138.00","periods_num":1000,"transaction_id":"4200000844202011226885703491","balance":"126.65","top_limit":"138.00","total_abonus":"11.35","type":0,"times":105,"create_time":1606050094,"update_time":1606992655,"reward_money":"5.83","refund_money":"5.43","finish_time":1608642094,"small_change":"0.00"},{"receives_id":3531,"user_id":16208,"account":"oYUO75fl0KZ0mpLqJiA7vxnvFGc4","order_no":"2020112252515355","wxapp_id":43,"payment":"207.00","periods_num":1000,"transaction_id":"4200000809202011220530579207","balance":"195.74","top_limit":"207.00","total_abonus":"11.26","type":0,"times":104,"create_time":1606050496,"update_time":1606992655,"reward_money":"5.76","refund_money":"5.36","finish_time":1608642496,"small_change":"0.00"},{"receives_id":3539,"user_id":16218,"account":"oYUO75Y8JUIVpyt22aoGT6gSTw9o","order_no":"2020112253505051","wxapp_id":43,"payment":"226.00","periods_num":1000,"transaction_id":"4200000842202011220660563598","balance":"214.88","top_limit":"226.00","total_abonus":"11.12","type":0,"times":103,"create_time":1606052703,"update_time":1606992655,"reward_money":"5.65","refund_money":"5.32","finish_time":1608644703,"small_change":"0.00"},{"receives_id":3544,"user_id":16221,"account":"oYUO75dJOU-qDQ_Le9d2oKmpHuSo","order_no":"2020112248989855","wxapp_id":43,"payment":"168.00","periods_num":1000,"transaction_id":"4200000825202011223456902848","balance":"157.03","top_limit":"168.00","total_abonus":"10.97","type":0,"times":102,"create_time":1606054824,"update_time":1606992655,"reward_money":"5.56","refund_money":"5.30","finish_time":1608646824,"small_change":"0.00"},{"receives_id":3545,"user_id":16222,"account":"oYUO75Vny_Foq4EfNSpnaGpLv3Ts","order_no":"2020112249545156","wxapp_id":43,"payment":"413.00","periods_num":1000,"transaction_id":"4200000845202011222024861791","balance":"402.14","top_limit":"413.00","total_abonus":"10.86","type":0,"times":101,"create_time":1606055240,"update_time":1606992655,"reward_money":"5.41","refund_money":"5.17","finish_time":1608647240,"small_change":"0.00"},{"receives_id":3548,"user_id":16226,"account":"oYUO75ePR-0CoG8D-RWa__KnTDFk","order_no":"VIP2020112298485753","wxapp_id":43,"payment":"888.00","periods_num":1000,"transaction_id":"4200000814202011229038347470","balance":"877.42","top_limit":"888.00","total_abonus":"10.58","type":0,"times":100,"create_time":1606057924,"update_time":1606992655,"reward_money":"5.28","refund_money":"5.24","finish_time":1608649924,"small_change":"0.00"},{"receives_id":3550,"user_id":16227,"account":"oYUO75U19NxrRz2gAgSJ__PR1ydE","order_no":"2020112251544852","wxapp_id":43,"payment":"141.00","periods_num":1000,"transaction_id":"4200000823202011228463961043","balance":"130.48","top_limit":"141.00","total_abonus":"10.52","type":0,"times":99,"create_time":1606058682,"update_time":1606992655,"reward_money":"5.21","refund_money":"5.22","finish_time":1608650682,"small_change":"0.00"},{"receives_id":3551,"user_id":16228,"account":"oYUO75YcYX64SjoTIBvhFJUm6Lak","order_no":"2020112252571029","wxapp_id":43,"payment":"244.00","periods_num":1000,"transaction_id":"4200000846202011220743428510","balance":"233.57","top_limit":"244.00","total_abonus":"10.43","type":0,"times":98,"create_time":1606059726,"update_time":1606992655,"reward_money":"5.09","refund_money":"5.18","finish_time":1608651726,"small_change":"0.00"},{"receives_id":3570,"user_id":16300,"account":"oYUO75Tk7OUqP9Lf2PdYhdl2N0Tk","order_no":"2020112310055544","wxapp_id":43,"payment":"138.00","periods_num":1000,"transaction_id":"4200000848202011238679299560","balance":"127.73","top_limit":"138.00","total_abonus":"10.27","type":0,"times":97,"create_time":1606108324,"update_time":1606992655,"reward_money":"5.02","refund_money":"5.16","finish_time":1608700324,"small_change":"0.00"},{"receives_id":3573,"user_id":16274,"account":"oYUO75VcTc2HRAlXN0WT_LMndEN8","order_no":"2020112355485354","wxapp_id":43,"payment":"371.00","periods_num":1000,"transaction_id":"4200000818202011233732341374","balance":"360.82","top_limit":"371.00","total_abonus":"10.18","type":0,"times":96,"create_time":1606109950,"update_time":1606992655,"reward_money":"4.90","refund_money":"5.04","finish_time":1608701950,"small_change":"0.00"},{"receives_id":3575,"user_id":16311,"account":"oYUO75XBwYTTTZc3BrAJ7THMU92w","order_no":"2020112351545348","wxapp_id":43,"payment":"147.00","periods_num":1000,"transaction_id":"4200000824202011238445209051","balance":"137.06","top_limit":"147.00","total_abonus":"9.94","type":0,"times":95,"create_time":1606111000,"update_time":1606992655,"reward_money":"4.84","refund_money":"5.01","finish_time":1608703000,"small_change":"0.00"},{"receives_id":3576,"user_id":16313,"account":"oYUO75dX1P5kbkJjx7Rsl83LDPN8","order_no":"2020112350559755","wxapp_id":43,"payment":"214.00","periods_num":1000,"transaction_id":"4200000841202011233846469325","balance":"204.15","top_limit":"214.00","total_abonus":"9.85","type":0,"times":94,"create_time":1606111181,"update_time":1606992655,"reward_money":"4.75","refund_money":"4.97","finish_time":1608703181,"small_change":"0.00"},{"receives_id":3612,"user_id":16350,"account":"oYUO75U40pf6LRXTJUUapIeEEkis","order_no":"VIP2020112354569757","wxapp_id":43,"payment":"888.00","periods_num":1000,"transaction_id":"4200000811202011230669166715","balance":"882.91","top_limit":"888.00","total_abonus":"5.09","type":0,"times":47,"create_time":1606127614,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.91","finish_time":1608719614,"small_change":"0.00"},{"receives_id":3619,"user_id":16364,"account":"oYUO75enGSJZdRrGZj16taXNmX7w","order_no":"2020112357569756","wxapp_id":43,"payment":"183.00","periods_num":1000,"transaction_id":"4200000847202011236912740791","balance":"177.89","top_limit":"183.00","total_abonus":"5.11","type":0,"times":47,"create_time":1606131104,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.88","finish_time":1608723104,"small_change":"0.00"},{"receives_id":3622,"user_id":16344,"account":"oYUO75VyRlx0uTBRABDrNUS9I4H0","order_no":"2020112350974949","wxapp_id":43,"payment":"215.00","periods_num":1000,"transaction_id":"4200000824202011236976147889","balance":"209.79","top_limit":"215.00","total_abonus":"5.21","type":0,"times":47,"create_time":1606131784,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.96","finish_time":1608723784,"small_change":"0.00"},{"receives_id":3627,"user_id":16375,"account":"oYUO75Umhn77V5VqfXLrxiOyyh_0","order_no":"2020112310110053","wxapp_id":43,"payment":"187.00","periods_num":1000,"transaction_id":"4200000842202011239179840326","balance":"181.87","top_limit":"187.00","total_abonus":"5.13","type":0,"times":47,"create_time":1606132718,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.90","finish_time":1608724718,"small_change":"0.00"},{"receives_id":3628,"user_id":16376,"account":"oYUO75QaluzT33Yui3YdxjqJ3FoM","order_no":"2020112398525651","wxapp_id":43,"payment":"158.00","periods_num":1000,"transaction_id":"4200000810202011231296303818","balance":"152.92","top_limit":"158.00","total_abonus":"5.08","type":0,"times":47,"create_time":1606132855,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.87","finish_time":1608724855,"small_change":"0.00"},{"receives_id":3631,"user_id":16381,"account":"oYUO75cnSeqFSJnfVdpQOS96KkZQ","order_no":"2020112352561025","wxapp_id":43,"payment":"253.00","periods_num":1000,"transaction_id":"4200000819202011238536465059","balance":"247.92","top_limit":"253.00","total_abonus":"5.08","type":0,"times":47,"create_time":1606133209,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.81","finish_time":1608725209,"small_change":"0.00"},{"receives_id":3632,"user_id":16382,"account":"oYUO75dgaTNRh_FuoYpZ496ObVec","order_no":"2020112348505010","wxapp_id":43,"payment":"179.00","periods_num":1000,"transaction_id":"4200000817202011232615019995","balance":"173.92","top_limit":"179.00","total_abonus":"5.08","type":0,"times":47,"create_time":1606133510,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.85","finish_time":1608725510,"small_change":"0.00"},{"receives_id":3634,"user_id":16384,"account":"oYUO75fevhSmw94LEo5GBCZ1xsLw","order_no":"2020112310110152","wxapp_id":43,"payment":"275.00","periods_num":1000,"transaction_id":"4200000820202011235885552422","balance":"269.99","top_limit":"275.00","total_abonus":"5.01","type":0,"times":47,"create_time":1606133694,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.73","finish_time":1608725694,"small_change":"0.00"},{"receives_id":3635,"user_id":16385,"account":"oYUO75RCBwLmiHvlvj6bMkSSO9f4","order_no":"2020112356569952","wxapp_id":43,"payment":"156.00","periods_num":1000,"transaction_id":"4200000814202011238756579959","balance":"151.00","top_limit":"156.00","total_abonus":"5.00","type":0,"times":47,"create_time":1606133737,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.79","finish_time":1608725737,"small_change":"0.00"},{"receives_id":3640,"user_id":16392,"account":"oYUO75V5POSb4Xa9GD4eV_ULQgbQ","order_no":"2020112351989749","wxapp_id":43,"payment":"150.00","periods_num":1000,"transaction_id":"4200000825202011235766320053","balance":"144.98","top_limit":"150.00","total_abonus":"5.02","type":0,"times":47,"create_time":1606135722,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.81","finish_time":1608727722,"small_change":"0.00"},{"receives_id":3641,"user_id":16393,"account":"oYUO75Yaowwtgknu4sFfcuYiLPXo","order_no":"2020112397485297","wxapp_id":43,"payment":"189.00","periods_num":1000,"transaction_id":"4200000844202011235858033963","balance":"183.97","top_limit":"189.00","total_abonus":"5.03","type":0,"times":47,"create_time":1606136001,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.80","finish_time":1608728001,"small_change":"0.00"},{"receives_id":3642,"user_id":16353,"account":"oYUO75Seq-JUoC8K24LscsSwLIQs","order_no":"2020112310056975","wxapp_id":43,"payment":"357.00","periods_num":1000,"transaction_id":"4200000811202011239493676555","balance":"351.99","top_limit":"357.00","total_abonus":"5.01","type":0,"times":47,"create_time":1606136370,"update_time":1606992655,"reward_money":"0.12","refund_money":"4.68","finish_time":1608728370,"small_change":"0.00"},{"receives_id":3643,"user_id":16396,"account":"oYUO75XDX2-8gkGKA1e4Vg4MMplA","order_no":"2020112397505050","wxapp_id":43,"payment":"141.00","periods_num":1000,"transaction_id":"4200000813202011230624523571","balance":"136.13","top_limit":"141.00","total_abonus":"4.87","type":0,"times":47,"create_time":1606136991,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.67","finish_time":1608728991,"small_change":"0.00"},{"receives_id":3645,"user_id":16399,"account":"oYUO75WKEqkY_PE7wllfWuG2Kh38","order_no":"2020112350525052","wxapp_id":43,"payment":"226.00","periods_num":1000,"transaction_id":"4200000817202011231250732929","balance":"221.12","top_limit":"226.00","total_abonus":"4.88","type":0,"times":47,"create_time":1606138439,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.63","finish_time":1608730439,"small_change":"0.00"},{"receives_id":3646,"user_id":16362,"account":"oYUO75cpq1MwJ4zJhfTNJw-XnkpI","order_no":"2020112351100515","wxapp_id":43,"payment":"379.00","periods_num":1000,"transaction_id":"4200000817202011231555470010","balance":"374.12","top_limit":"379.00","total_abonus":"4.88","type":0,"times":47,"create_time":1606139370,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.54","finish_time":1608731370,"small_change":"0.00"},{"receives_id":3647,"user_id":16401,"account":"oYUO75R58RD-S9uJHIXJ9veCO_w8","order_no":"2020112356481025","wxapp_id":43,"payment":"163.00","periods_num":1000,"transaction_id":"4200000846202011237058688166","balance":"158.17","top_limit":"163.00","total_abonus":"4.83","type":0,"times":47,"create_time":1606140064,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.62","finish_time":1608732064,"small_change":"0.00"},{"receives_id":3649,"user_id":16403,"account":"oYUO75Xt-jtKdNn9DpED-uf6--FA","order_no":"2020112397975310","wxapp_id":43,"payment":"181.00","periods_num":1000,"transaction_id":"4200000813202011238116595777","balance":"176.16","top_limit":"181.00","total_abonus":"4.84","type":0,"times":47,"create_time":1606140928,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.62","finish_time":1608732928,"small_change":"0.00"},{"receives_id":4024,"user_id":17002,"account":"oYUO75e62fmshlz0-Qpt_GNBGHSw","order_no":"VIP5023531188151387","wxapp_id":43,"payment":"888.00","periods_num":1000,"transaction_id":"4200000818202011271662068031","balance":"883.09","top_limit":"888.00","total_abonus":"4.91","type":0,"times":47,"create_time":1606469892,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.74","finish_time":1609061892,"small_change":"0.00"}]';
        $arr = json_decode($jsarr1,true);
        //   pre($arr);

        foreach ($arr as $key=>$value){
            $extends=db('divide_receives_user')->where('receives_id',$value['receives_id'])->value('extend');

            $data = json_decode($extends, true);
            if(count($data)>1){
                //把查询出来的数据转成数据

                //获取最后一个数组
//                $lastData=end($data);
                //   $this->log('最后一个数组',$lastData);
                //存在的话，把最后一个数组删除
                array_pop( $data);
                $res = json_encode($data);
                db('divide_receives_user')->where('receives_id',$value['receives_id'])->setField('extend',$res);
            }
        }

    }
    public function dson3(){
        $params=$this->request->param();
//        $dataList=db('divide_receives')->where(['wxapp_id'=>$params['id'],'periods_num'=>$params['num'],'type'=>0])->field('receives_id')->order('receives_id asc')->select();
//        $this->log('分账用户',$dataList);
        $jsarr2='[{"receives_id":4029,"user_id":17009,"account":"oYUO75d-xR5jWM3uXikX0iOrEKRA","order_no":"5023546746011988","wxapp_id":43,"payment":"276.00","periods_num":1000,"transaction_id":"4200000824202011270083555114","balance":"271.05","top_limit":"276.00","total_abonus":"4.95","type":0,"times":47,"create_time":1606473690,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.68","finish_time":1609065690,"small_change":"0.00"},{"receives_id":4038,"user_id":17023,"account":"oYUO75TO51_j_VD-CHKJZgCDiXSE","order_no":"5023557664231475","wxapp_id":43,"payment":"192.00","periods_num":1000,"transaction_id":"4200000843202011277359570417","balance":"187.14","top_limit":"192.00","total_abonus":"4.86","type":0,"times":47,"create_time":1606476355,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.64","finish_time":1609068355,"small_change":"0.00"},{"receives_id":4065,"user_id":17059,"account":"oYUO75brCgMRBKaL3ugKpmGVB-BY","order_no":"5023572051720730","wxapp_id":43,"payment":"241.00","periods_num":1000,"transaction_id":"4200000846202011279751439257","balance":"236.18","top_limit":"241.00","total_abonus":"4.82","type":0,"times":47,"create_time":1606479868,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.57","finish_time":1609071868,"small_change":"0.00"},{"receives_id":4067,"user_id":17060,"account":"oYUO75aO7f1xs0z3SnQi4ggfyhok","order_no":"5023573293857997","wxapp_id":43,"payment":"240.00","periods_num":1000,"transaction_id":"4200000820202011275755155612","balance":"235.21","top_limit":"240.00","total_abonus":"4.79","type":0,"times":47,"create_time":1606480171,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.54","finish_time":1609072171,"small_change":"0.00"},{"receives_id":4068,"user_id":17061,"account":"oYUO75bMKht2Bx21m7Et6Jo9Q18U","order_no":"5023574582367615","wxapp_id":43,"payment":"349.00","periods_num":1000,"transaction_id":"4200000843202011277471896273","balance":"344.10","top_limit":"349.00","total_abonus":"4.90","type":0,"times":47,"create_time":1606480492,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.59","finish_time":1609072492,"small_change":"0.00"},{"receives_id":4069,"user_id":17062,"account":"oYUO75ZuelMpfqvKV-OwzYMBXQHE","order_no":"5023575143669246","wxapp_id":43,"payment":"311.00","periods_num":1000,"transaction_id":"4200000816202011276713786233","balance":"306.19","top_limit":"311.00","total_abonus":"4.81","type":0,"times":47,"create_time":1606480643,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.52","finish_time":1609072643,"small_change":"0.00"},{"receives_id":4071,"user_id":17064,"account":"oYUO75Yo3NIriNCJzhPfZq6zOrAU","order_no":"5023575951479195","wxapp_id":43,"payment":"170.00","periods_num":1000,"transaction_id":"4200000845202011274975501914","balance":"165.23","top_limit":"170.00","total_abonus":"4.77","type":0,"times":47,"create_time":1606480822,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.56","finish_time":1609072822,"small_change":"0.00"},{"receives_id":4076,"user_id":17068,"account":"oYUO75d849r4DrGSjGT4SnThxNno","order_no":"5023577601884279","wxapp_id":43,"payment":"195.00","periods_num":1000,"transaction_id":"4200000812202011273825042249","balance":"190.21","top_limit":"195.00","total_abonus":"4.79","type":0,"times":47,"create_time":1606481273,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.57","finish_time":1609073273,"small_change":"0.00"},{"receives_id":4090,"user_id":17089,"account":"oYUO75dF7qGWRgbntDu-OveLi8js","order_no":"5023608163840072","wxapp_id":43,"payment":"141.00","periods_num":1000,"transaction_id":"4200000848202011275992836162","balance":"136.24","top_limit":"141.00","total_abonus":"4.76","type":0,"times":47,"create_time":1606488683,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.57","finish_time":1609080683,"small_change":"0.00"},{"receives_id":4091,"user_id":17090,"account":"oYUO75Szttj7KLVkgolnUcd8hX4U","order_no":"5023610336129906","wxapp_id":43,"payment":"210.00","periods_num":1000,"transaction_id":"4200000828202011276561276715","balance":"205.27","top_limit":"210.00","total_abonus":"4.73","type":0,"times":47,"create_time":1606489216,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.50","finish_time":1609081216,"small_change":"0.00"},{"receives_id":4094,"user_id":17094,"account":"oYUO75YHemz5kZnNnfNOIeGfpqL4","order_no":"5023622658870241","wxapp_id":43,"payment":"263.00","periods_num":1000,"transaction_id":"4200000812202011273919776061","balance":"258.21","top_limit":"263.00","total_abonus":"4.79","type":0,"times":47,"create_time":1606492224,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.53","finish_time":1609084224,"small_change":"0.00"},{"receives_id":4095,"user_id":17095,"account":"oYUO75XFDC1qUlZa4Kgn7E49elCE","order_no":"5023625246198899","wxapp_id":43,"payment":"266.00","periods_num":1000,"transaction_id":"4200000847202011286113846208","balance":"261.22","top_limit":"266.00","total_abonus":"4.78","type":0,"times":47,"create_time":1606492859,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.52","finish_time":1609084859,"small_change":"0.00"},{"receives_id":4109,"user_id":17137,"account":"oYUO75SGhI6jNiqvtzXqZIInAGy8","order_no":"VIP5023820392347906","wxapp_id":43,"payment":"888.00","periods_num":1000,"transaction_id":"4200000826202011287738045263","balance":"883.29","top_limit":"888.00","total_abonus":"4.71","type":0,"times":47,"create_time":1606540517,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.54","finish_time":1609132517,"small_change":"0.00"},{"receives_id":4125,"user_id":17161,"account":"oYUO75dWGwvGp_a8lcCgJvO0o0hk","order_no":"5023848639140837","wxapp_id":43,"payment":"182.00","periods_num":1000,"transaction_id":"4200000815202011280492303824","balance":"177.24","top_limit":"182.00","total_abonus":"4.76","type":0,"times":47,"create_time":1606547404,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.55","finish_time":1609139404,"small_change":"0.00"},{"receives_id":4127,"user_id":17162,"account":"oYUO75baIAEe_qu5oTXMKDRH8D20","order_no":"5023850762562742","wxapp_id":43,"payment":"236.00","periods_num":1000,"transaction_id":"4200000820202011287609632413","balance":"231.26","top_limit":"236.00","total_abonus":"4.74","type":0,"times":47,"create_time":1606547911,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.50","finish_time":1609139911,"small_change":"0.00"},{"receives_id":4166,"user_id":17225,"account":"oYUO75b43B6D01DmRBLIuTgjtrlw","order_no":"5023919091580542","wxapp_id":43,"payment":"138.00","periods_num":1000,"transaction_id":"4200000817202011281377040383","balance":"133.29","top_limit":"138.00","total_abonus":"4.71","type":0,"times":47,"create_time":1606564595,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.52","finish_time":1609156595,"small_change":"0.00"},{"receives_id":4174,"user_id":15450,"account":"oYUO75djwzKJsbYGvmTJ4hEGID_8","order_no":"5023924759537291","wxapp_id":43,"payment":"219.00","periods_num":1000,"transaction_id":"4200000844202011282470774798","balance":"214.30","top_limit":"219.00","total_abonus":"4.70","type":0,"times":47,"create_time":1606565984,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.47","finish_time":1609157984,"small_change":"0.00"},{"receives_id":4176,"user_id":17237,"account":"oYUO75UzVKkGuEWwUMMXs82A7lCQ","order_no":"5023925312809550","wxapp_id":43,"payment":"190.00","periods_num":1000,"transaction_id":"4200000818202011280024084813","balance":"184.80","top_limit":"190.00","total_abonus":"5.20","type":0,"times":53,"create_time":1606566133,"update_time":1606992654,"reward_money":"0.55","refund_money":"4.56","finish_time":1609158133,"small_change":"0.00"},{"receives_id":4177,"user_id":17194,"account":"oYUO75RfnVhvIV6ryzNjEU9GiHoc","order_no":"5023926204368626","wxapp_id":43,"payment":"298.00","periods_num":1000,"transaction_id":"4200000818202011280774636637","balance":"292.82","top_limit":"298.00","total_abonus":"5.18","type":0,"times":53,"create_time":1606566332,"update_time":1606992654,"reward_money":"0.55","refund_money":"4.48","finish_time":1609158332,"small_change":"0.00"},{"receives_id":4179,"user_id":17240,"account":"oYUO75VlM1Shz9RNRtFRPdQ5ozns","order_no":"5023926944023670","wxapp_id":43,"payment":"259.00","periods_num":1000,"transaction_id":"4200000828202011289142284474","balance":"253.83","top_limit":"259.00","total_abonus":"5.17","type":0,"times":53,"create_time":1606566511,"update_time":1606992654,"reward_money":"0.55","refund_money":"4.49","finish_time":1609158511,"small_change":"0.00"},{"receives_id":4182,"user_id":17244,"account":"oYUO75Ua-rW6mqAeRoHUaWDlM5rk","order_no":"5023928043628516","wxapp_id":43,"payment":"145.00","periods_num":1000,"transaction_id":"4200000843202011280472922638","balance":"139.89","top_limit":"145.00","total_abonus":"5.11","type":0,"times":53,"create_time":1606566779,"update_time":1606992654,"reward_money":"0.55","refund_money":"4.49","finish_time":1609158779,"small_change":"0.00"},{"receives_id":4191,"user_id":17253,"account":"oYUO75TjtlAso65_lLlSEXFfcO_Y","order_no":"5023931643137570","wxapp_id":43,"payment":"241.00","periods_num":1000,"transaction_id":"4200000812202011286294351205","balance":"235.79","top_limit":"241.00","total_abonus":"5.21","type":0,"times":53,"create_time":1606567661,"update_time":1606992654,"reward_money":"0.55","refund_money":"4.54","finish_time":1609159661,"small_change":"0.00"},{"receives_id":4194,"user_id":17257,"account":"oYUO75d-J76z5BILbJHRAv9e0nx4","order_no":"5023935044194201","wxapp_id":43,"payment":"153.00","periods_num":1000,"transaction_id":"4200000847202011285882378650","balance":"147.91","top_limit":"153.00","total_abonus":"5.09","type":0,"times":52,"create_time":1606568492,"update_time":1606992654,"reward_money":"0.49","refund_money":"4.53","finish_time":1609160492,"small_change":"0.00"},{"receives_id":4198,"user_id":17263,"account":"oYUO75V2Wh63xGixt5JIWBvVFMyg","order_no":"5023937869910319","wxapp_id":43,"payment":"259.00","periods_num":1000,"transaction_id":"4200000821202011284607248903","balance":"253.98","top_limit":"259.00","total_abonus":"5.02","type":0,"times":51,"create_time":1606569250,"update_time":1606992654,"reward_money":"0.44","refund_money":"4.46","finish_time":1609161250,"small_change":"0.00"},{"receives_id":4199,"user_id":17265,"account":"oYUO75aJOxn_ljL1nRWWuGhq6Uls","order_no":"5023939857999783","wxapp_id":43,"payment":"192.00","periods_num":1000,"transaction_id":"4200000811202011284504300865","balance":"187.16","top_limit":"192.00","total_abonus":"4.84","type":0,"times":49,"create_time":1606569675,"update_time":1606992654,"reward_money":"0.17","refund_money":"4.58","finish_time":1609161675,"small_change":"0.00"},{"receives_id":4205,"user_id":17275,"account":"oYUO75crCfOCNpW_95cfu_irpSZQ","order_no":"5023964433071674","wxapp_id":43,"payment":"362.00","periods_num":1000,"transaction_id":"4200000841202011286842389525","balance":"357.25","top_limit":"362.00","total_abonus":"4.75","type":0,"times":48,"create_time":1606575665,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.46","finish_time":1609167665,"small_change":"0.00"},{"receives_id":4228,"user_id":17287,"account":"oYUO75UhcWYuRGFW9Zh88JYMSW6g","order_no":"5024147824639736","wxapp_id":43,"payment":"174.00","periods_num":1000,"transaction_id":"4200000844202011293327290666","balance":"169.42","top_limit":"174.00","total_abonus":"4.58","type":0,"times":47,"create_time":1606620486,"update_time":1606992654,"reward_money":"0.12","refund_money":"4.38","finish_time":1609212486,"small_change":"0.00"},{"receives_id":4247,"user_id":17307,"account":"oYUO75XLpzOyWnB7Rw9rpAUdxacI","order_no":"VIP5024182276689476","wxapp_id":43,"payment":"888.00","periods_num":1000,"transaction_id":"4200000843202011297503100226","balance":"883.55","top_limit":"888.00","total_abonus":"4.45","type":0,"times":45,"create_time":1606628850,"update_time":1606992654,"reward_money":"0.00","refund_money":"4.41","finish_time":1609220850,"small_change":"0.00"},{"receives_id":4270,"user_id":15450,"account":"oYUO75djwzKJsbYGvmTJ4hEGID_8","order_no":"5024205307551795","wxapp_id":43,"payment":"247.00","periods_num":1000,"transaction_id":"4200000842202011296470881863","balance":"242.59","top_limit":"247.00","total_abonus":"4.41","type":0,"times":44,"create_time":1606634476,"update_time":1606992653,"reward_money":"0.00","refund_money":"4.30","finish_time":1609226476,"small_change":"0.00"},{"receives_id":4277,"user_id":17364,"account":"oYUO75bRE4Tt4sKs7L3Y2-uE6do4","order_no":"5024228781994552","wxapp_id":43,"payment":"201.00","periods_num":1000,"transaction_id":"4200000817202011296950507551","balance":"196.70","top_limit":"201.00","total_abonus":"4.30","type":0,"times":43,"create_time":1606640203,"update_time":1606992652,"reward_money":"0.00","refund_money":"4.21","finish_time":1609232203,"small_change":"0.00"},{"receives_id":4278,"user_id":17365,"account":"oYUO75dTZbqTxOvUQPu5SrSF0xaQ","order_no":"5024230528802783","wxapp_id":43,"payment":"147.00","periods_num":1000,"transaction_id":"4200000848202011296231101531","balance":"142.79","top_limit":"147.00","total_abonus":"4.21","type":0,"times":42,"create_time":1606640630,"update_time":1606992651,"reward_money":"0.00","refund_money":"4.14","finish_time":1609232630,"small_change":"0.00"},{"receives_id":4283,"user_id":17376,"account":"oYUO75Xu7nDq1tvouXbtYURee9hY","order_no":"5024246553026587","wxapp_id":43,"payment":"304.00","periods_num":1000,"transaction_id":"4200000828202011291639598469","balance":"299.86","top_limit":"304.00","total_abonus":"4.14","type":0,"times":41,"create_time":1606644552,"update_time":1606992650,"reward_money":"0.00","refund_money":"4.00","finish_time":1609236552,"small_change":"0.00"},{"receives_id":4293,"user_id":17394,"account":"oYUO75e61Fu01W8AQLrw26bgzkEc","order_no":"5024261159129513","wxapp_id":43,"payment":"154.00","periods_num":1000,"transaction_id":"4200000846202011290606936337","balance":"150.00","top_limit":"154.00","total_abonus":"4.00","type":0,"times":40,"create_time":1606648107,"update_time":1606992649,"reward_money":"0.00","refund_money":"3.93","finish_time":1609240107,"small_change":"0.00"},{"receives_id":4298,"user_id":17399,"account":"oYUO75Tg-5_HbP27mmSX5MmSqPzo","order_no":"5024267522804491","wxapp_id":43,"payment":"449.00","periods_num":1000,"transaction_id":"4200000842202011290089581522","balance":"445.07","top_limit":"449.00","total_abonus":"3.93","type":0,"times":39,"create_time":1606649668,"update_time":1606992648,"reward_money":"0.00","refund_money":"3.72","finish_time":1609241668,"small_change":"0.00"},{"receives_id":4304,"user_id":17407,"account":"oYUO75cL-Zfl9PpKV70Ebu7Qy-EA","order_no":"5024275915385710","wxapp_id":43,"payment":"192.00","periods_num":1000,"transaction_id":"4200000817202011292401143894","balance":"188.34","top_limit":"192.00","total_abonus":"3.66","type":0,"times":37,"create_time":1606651709,"update_time":1606992647,"reward_money":"0.00","refund_money":"3.57","finish_time":1609243709,"small_change":"0.00"},{"receives_id":4307,"user_id":17411,"account":"oYUO75e5E3rKS1W3FO5e3Uk02BhI","order_no":"5024277327140200","wxapp_id":43,"payment":"324.00","periods_num":1000,"transaction_id":"4200000810202011298054079839","balance":"320.43","top_limit":"324.00","total_abonus":"3.57","type":0,"times":36,"create_time":1606652055,"update_time":1606992646,"reward_money":"0.00","refund_money":"3.42","finish_time":1609244055,"small_change":"0.00"},{"receives_id":4315,"user_id":17414,"account":"oYUO75VbfV4LwV2D2-E6F8PwxD-Y","order_no":"5024286287706194","wxapp_id":43,"payment":"325.00","periods_num":1000,"transaction_id":"4200000810202011291807253443","balance":"321.58","top_limit":"325.00","total_abonus":"3.42","type":0,"times":35,"create_time":1606654242,"update_time":1606992645,"reward_money":"0.00","refund_money":"3.27","finish_time":1609246242,"small_change":"0.00"},{"receives_id":4319,"user_id":17418,"account":"oYUO75eIE7pxJYxQbtw6G0hXjzNU","order_no":"5024289741904834","wxapp_id":43,"payment":"226.00","periods_num":1000,"transaction_id":"4200000817202011298093357372","balance":"222.73","top_limit":"226.00","total_abonus":"3.27","type":0,"times":34,"create_time":1606655084,"update_time":1606992644,"reward_money":"0.00","refund_money":"3.17","finish_time":1609247084,"small_change":"0.00"},{"receives_id":4321,"user_id":17420,"account":"oYUO75ZcNTnw3N4jRyqiMHhhcKoA","order_no":"5024292590142609","wxapp_id":43,"payment":"212.00","periods_num":1000,"transaction_id":"4200000842202011293879815703","balance":"208.83","top_limit":"212.00","total_abonus":"3.17","type":0,"times":33,"create_time":1606655780,"update_time":1606992643,"reward_money":"0.00","refund_money":"3.08","finish_time":1609247780,"small_change":"0.00"},{"receives_id":4323,"user_id":17423,"account":"oYUO75foF_tl0GjFMk7L-Um2C1ok","order_no":"5024299033031701","wxapp_id":43,"payment":"175.00","periods_num":1000,"transaction_id":"4200000845202011292006948645","balance":"171.92","top_limit":"175.00","total_abonus":"3.08","type":0,"times":32,"create_time":1606657354,"update_time":1606992642,"reward_money":"0.00","refund_money":"3.01","finish_time":1609249354,"small_change":"0.00"},{"receives_id":4324,"user_id":17424,"account":"oYUO75QDsKbooDZnfcGj2RpeMmWc","order_no":"5024299841889648","wxapp_id":43,"payment":"201.00","periods_num":1000,"transaction_id":"4200000812202011293615269227","balance":"197.99","top_limit":"201.00","total_abonus":"3.01","type":0,"times":31,"create_time":1606657556,"update_time":1606992641,"reward_money":"0.00","refund_money":"2.92","finish_time":1609249556,"small_change":"0.00"},{"receives_id":4326,"user_id":13712,"account":"oYUO75ZTsRAJZcqLW1NPWANrW77M","order_no":"5024301285225743","wxapp_id":43,"payment":"296.00","periods_num":1000,"transaction_id":"4200000823202011298032174697","balance":"293.08","top_limit":"296.00","total_abonus":"2.92","type":0,"times":30,"create_time":1606657908,"update_time":1606992640,"reward_money":"0.00","refund_money":"2.79","finish_time":1609249908,"small_change":"0.00"},{"receives_id":4327,"user_id":17425,"account":"oYUO75bb4L3mlc8XJmfGZEiQ7PKA","order_no":"5024308172664178","wxapp_id":43,"payment":"392.00","periods_num":1000,"transaction_id":"4200000843202011291071774608","balance":"389.21","top_limit":"392.00","total_abonus":"2.79","type":0,"times":29,"create_time":1606659583,"update_time":1606992639,"reward_money":"0.00","refund_money":"2.62","finish_time":1609251583,"small_change":"0.00"},{"receives_id":4329,"user_id":17428,"account":"oYUO75dya8Tq43NP8zV2OmeC7dR8","order_no":"5024323452288498","wxapp_id":43,"payment":"234.00","periods_num":1000,"transaction_id":"4200000846202011292746628971","balance":"231.38","top_limit":"234.00","total_abonus":"2.62","type":0,"times":28,"create_time":1606663315,"update_time":1606992638,"reward_money":"0.00","refund_money":"2.52","finish_time":1609255315,"small_change":"0.00"},{"receives_id":4349,"user_id":17492,"account":"oYUO75ToO-efwlfZP-32OsE1xiUw","order_no":"5024546347578963","wxapp_id":43,"payment":"233.00","periods_num":1000,"transaction_id":"4200000823202011307891681137","balance":"230.48","top_limit":"233.00","total_abonus":"2.52","type":0,"times":27,"create_time":1606717732,"update_time":1606992637,"reward_money":"0.00","refund_money":"2.42","finish_time":1609309732,"small_change":"0.00"},{"receives_id":4351,"user_id":17495,"account":"oYUO75YPXN-518LCOcZnb6dZH2iA","order_no":"5024549412282947","wxapp_id":43,"payment":"211.00","periods_num":1000,"transaction_id":"4200000844202011309989238564","balance":"208.58","top_limit":"211.00","total_abonus":"2.42","type":0,"times":26,"create_time":1606718481,"update_time":1606992636,"reward_money":"0.00","refund_money":"2.33","finish_time":1609310481,"small_change":"0.00"},{"receives_id":4357,"user_id":17510,"account":"oYUO75WflcYz--kr2O_8cBte7mqY","order_no":"5024560368374167","wxapp_id":43,"payment":"223.00","periods_num":1000,"transaction_id":"4200000827202011307978346212","balance":"220.67","top_limit":"223.00","total_abonus":"2.33","type":0,"times":25,"create_time":1606721211,"update_time":1606992635,"reward_money":"0.00","refund_money":"2.24","finish_time":1609313211,"small_change":"0.00"},{"receives_id":4384,"user_id":17581,"account":"oYUO75fgpSdyj24Gjk80w72rxNQA","order_no":"5024626514871366","wxapp_id":43,"payment":"146.00","periods_num":1000,"transaction_id":"4200000810202011308188458082","balance":"143.76","top_limit":"146.00","total_abonus":"2.24","type":0,"times":24,"create_time":1606737306,"update_time":1606992634,"reward_money":"0.00","refund_money":"2.18","finish_time":1609329306,"small_change":"0.00"},{"receives_id":4385,"user_id":17582,"account":"oYUO75etM_1fdoZDGEI4C1C_bo2s","order_no":"5024627282668757","wxapp_id":43,"payment":"148.00","periods_num":1000,"transaction_id":"4200000822202011303630767524","balance":"145.82","top_limit":"148.00","total_abonus":"2.18","type":0,"times":23,"create_time":1606737499,"update_time":1606992633,"reward_money":"0.00","refund_money":"2.12","finish_time":1609329499,"small_change":"0.00"},{"receives_id":4387,"user_id":17586,"account":"oYUO75WOyW39ucdHa3BiB9eM6al4","order_no":"5024631721115491","wxapp_id":43,"payment":"243.00","periods_num":1000,"transaction_id":"4200000819202011302145593939","balance":"240.88","top_limit":"243.00","total_abonus":"2.12","type":0,"times":22,"create_time":1606738575,"update_time":1606992632,"reward_money":"0.00","refund_money":"2.02","finish_time":1609330575,"small_change":"0.00"},{"receives_id":4394,"user_id":17597,"account":"oYUO75d3t9yJIWZRiS83DX1DmXB4","order_no":"5024640629847513","wxapp_id":43,"payment":"565.00","periods_num":1000,"transaction_id":"4200000809202011305411078882","balance":"562.98","top_limit":"565.00","total_abonus":"2.02","type":0,"times":21,"create_time":1606740750,"update_time":1606992631,"reward_money":"0.00","refund_money":"1.78","finish_time":1609332750,"small_change":"0.00"},{"receives_id":4395,"user_id":17600,"account":"oYUO75ZMVMzgXmWMuwUMeJwzskbY","order_no":"5024644129181275","wxapp_id":43,"payment":"253.00","periods_num":1000,"transaction_id":"4200000828202011301073416533","balance":"251.22","top_limit":"253.00","total_abonus":"1.78","type":0,"times":20,"create_time":1606741605,"update_time":1606992630,"reward_money":"0.00","refund_money":"1.68","finish_time":1609333605,"small_change":"0.00"},{"receives_id":4398,"user_id":17603,"account":"oYUO75T7SpTygprTpMrDpruB6ddY","order_no":"5024644929103244","wxapp_id":43,"payment":"312.00","periods_num":1000,"transaction_id":"4200000823202011308066178397","balance":"310.32","top_limit":"312.00","total_abonus":"1.68","type":0,"times":19,"create_time":1606741809,"update_time":1606992629,"reward_money":"0.00","refund_money":"1.55","finish_time":1609333809,"small_change":"0.00"},{"receives_id":4401,"user_id":17606,"account":"oYUO75YpU6AqHcBpAJnIU4vvvqPo","order_no":"5024648647458079","wxapp_id":43,"payment":"263.00","periods_num":1000,"transaction_id":"4200000825202011301813294407","balance":"261.45","top_limit":"263.00","total_abonus":"1.55","type":0,"times":18,"create_time":1606742725,"update_time":1606992628,"reward_money":"0.00","refund_money":"1.44","finish_time":1609334725,"small_change":"0.00"},{"receives_id":4406,"user_id":17611,"account":"oYUO75Wfzmz6LPJ_7gkJ-tnTF18s","order_no":"5024659795871799","wxapp_id":43,"payment":"170.00","periods_num":1000,"transaction_id":"4200000810202011307497191368","balance":"168.56","top_limit":"170.00","total_abonus":"1.44","type":0,"times":17,"create_time":1606745431,"update_time":1606992627,"reward_money":"0.00","refund_money":"1.37","finish_time":1609337431,"small_change":"0.00"},{"receives_id":4413,"user_id":15450,"account":"oYUO75djwzKJsbYGvmTJ4hEGID_8","order_no":"VIP5024674610491215","wxapp_id":43,"payment":"888.00","periods_num":1000,"transaction_id":"4200000815202011309841860069","balance":"886.63","top_limit":"888.00","total_abonus":"1.37","type":0,"times":16,"create_time":1606749048,"update_time":1606992627,"reward_money":"0.00","refund_money":"1.33","finish_time":1609341048,"small_change":"0.00"},{"receives_id":4415,"user_id":17620,"account":"oYUO75bmrjLzhmddpkuZpCt0PVJM","order_no":"5024683737848449","wxapp_id":43,"payment":"406.00","periods_num":1000,"transaction_id":"4200000843202011302186601596","balance":"404.67","top_limit":"406.00","total_abonus":"1.33","type":0,"times":15,"create_time":1606751285,"update_time":1606992626,"reward_money":"0.00","refund_money":"1.16","finish_time":1609343285,"small_change":"0.00"},{"receives_id":4416,"user_id":17622,"account":"oYUO75Qmq67YFbHoRRRwvHEZm1T0","order_no":"5024686065358385","wxapp_id":43,"payment":"326.00","periods_num":1000,"transaction_id":"4200000826202011308802056952","balance":"324.84","top_limit":"326.00","total_abonus":"1.16","type":0,"times":14,"create_time":1606751846,"update_time":1606992625,"reward_money":"0.00","refund_money":"1.03","finish_time":1609343846,"small_change":"0.00"},{"receives_id":4417,"user_id":17623,"account":"oYUO75fCsu7nZcZ0ky7EZafGEfyQ","order_no":"5024699549012192","wxapp_id":43,"payment":"182.00","periods_num":1000,"transaction_id":"4200000816202012013789512964","balance":"180.97","top_limit":"182.00","total_abonus":"1.03","type":0,"times":13,"create_time":1606755146,"update_time":1606992624,"reward_money":"0.00","refund_money":"0.96","finish_time":1609347146,"small_change":"0.00"},{"receives_id":4458,"user_id":17758,"account":"oYUO75esaNTW7xxFSmhvRiFQ-9d0","order_no":"5024963302552953","wxapp_id":43,"payment":"255.00","periods_num":1000,"transaction_id":"4200000825202012016090528486","balance":"254.04","top_limit":"255.00","total_abonus":"0.96","type":0,"times":12,"create_time":1606819528,"update_time":1606992623,"reward_money":"0.00","refund_money":"0.86","finish_time":1609411528,"small_change":"0.00"},{"receives_id":4460,"user_id":17765,"account":"oYUO75cZkOL_lh7mJYrwyLoM-hTY","order_no":"5024970560203434","wxapp_id":43,"payment":"170.00","periods_num":1000,"transaction_id":"4200000823202012010690657750","balance":"169.14","top_limit":"170.00","total_abonus":"0.86","type":0,"times":11,"create_time":1606821301,"update_time":1606992622,"reward_money":"0.00","refund_money":"0.79","finish_time":1609413301,"small_change":"0.00"},{"receives_id":4463,"user_id":17768,"account":"oYUO75W4x3dSUXB6caNTNFlY_HFA","order_no":"5024977221417615","wxapp_id":43,"payment":"229.00","periods_num":1000,"transaction_id":"4200000820202012013450957269","balance":"228.21","top_limit":"229.00","total_abonus":"0.79","type":0,"times":10,"create_time":1606822927,"update_time":1606992621,"reward_money":"0.00","refund_money":"0.70","finish_time":1609414927,"small_change":"0.00"},{"receives_id":4471,"user_id":17774,"account":"oYUO75SEEhv4C0ThkPfV8yXTxkeU","order_no":"5024981845909106","wxapp_id":43,"payment":"150.00","periods_num":1000,"transaction_id":"4200000813202012019254302991","balance":"149.30","top_limit":"150.00","total_abonus":"0.70","type":0,"times":9,"create_time":1606824058,"update_time":1606992620,"reward_money":"0.00","refund_money":"0.64","finish_time":1609416058,"small_change":"0.00"},{"receives_id":4473,"user_id":17775,"account":"oYUO75YHx4qTP_2fezCIwAituKgE","order_no":"5024982330342179","wxapp_id":43,"payment":"229.00","periods_num":1000,"transaction_id":"4200000822202012018781472531","balance":"228.36","top_limit":"229.00","total_abonus":"0.64","type":0,"times":8,"create_time":1606824192,"update_time":1606992619,"reward_money":"0.00","refund_money":"0.55","finish_time":1609416192,"small_change":"0.00"},{"receives_id":4475,"user_id":17779,"account":"oYUO75c-XiXOSVPzLlVjuOi5apvA","order_no":"5024985377125203","wxapp_id":43,"payment":"171.00","periods_num":1000,"transaction_id":"4200000819202012019728780876","balance":"170.45","top_limit":"171.00","total_abonus":"0.55","type":0,"times":7,"create_time":1606824921,"update_time":1606992618,"reward_money":"0.00","refund_money":"0.49","finish_time":1609416921,"small_change":"0.00"},{"receives_id":4480,"user_id":17784,"account":"oYUO75eu3G6rZTTgYG8YiED164so","order_no":"5024992358115664","wxapp_id":43,"payment":"141.00","periods_num":1000,"transaction_id":"4200000810202012013674535913","balance":"140.51","top_limit":"141.00","total_abonus":"0.49","type":0,"times":6,"create_time":1606826622,"update_time":1606992617,"reward_money":"0.00","refund_money":"0.44","finish_time":1609418622,"small_change":"0.00"},{"receives_id":4491,"user_id":17788,"account":"oYUO75Qo-uKu3avv-itYhj0B7h7M","order_no":"5025012512077669","wxapp_id":43,"payment":"261.00","periods_num":1000,"transaction_id":"4200000844202012018327841791","balance":"260.56","top_limit":"261.00","total_abonus":"0.44","type":0,"times":5,"create_time":1606831543,"update_time":1606992616,"reward_money":"0.00","refund_money":"0.34","finish_time":1609423543,"small_change":"0.00"},{"receives_id":4494,"user_id":17797,"account":"oYUO75dPtvIpLFgBj4hj6-pREZbE","order_no":"5025014479300003","wxapp_id":43,"payment":"435.00","periods_num":1000,"transaction_id":"4200000844202012012691143115","balance":"434.66","top_limit":"435.00","total_abonus":"0.34","type":0,"times":4,"create_time":1606832022,"update_time":1606992615,"reward_money":"0.00","refund_money":"0.17","finish_time":1609424022,"small_change":"0.00"},{"receives_id":4495,"user_id":17800,"account":"oYUO75W255Zj-Zd0pI_BlSR3MqFI","order_no":"5025048129029548","wxapp_id":43,"payment":"146.00","periods_num":1000,"transaction_id":"4200000819202012020078941752","balance":"145.83","top_limit":"146.00","total_abonus":"0.17","type":0,"times":3,"create_time":1606840237,"update_time":1606992614,"reward_money":"0.00","refund_money":"0.12","finish_time":1609432237,"small_change":"0.00"},{"receives_id":4503,"user_id":17831,"account":"oYUO75XojaY1KdROAuAbYV_sZAY4","order_no":"5025226213010649","wxapp_id":43,"payment":"190.00","periods_num":1000,"transaction_id":"4200000814202012024523580852","balance":"189.88","top_limit":"190.00","total_abonus":"0.12","type":0,"times":2,"create_time":1606883717,"update_time":1606992613,"reward_money":"0.00","refund_money":"0.05","finish_time":1609475717,"small_change":"0.00"},{"receives_id":4600,"user_id":18079,"account":"oYUO75QM6jTuaOVjFV7oTgD0T-8g","order_no":"5025672003643793","wxapp_id":43,"payment":"151.00","periods_num":1000,"transaction_id":"4200000820202012030507112649","balance":"150.95","top_limit":"151.00","total_abonus":"0.05","type":0,"times":1,"create_time":1606992553,"update_time":1606992553,"reward_money":"0.00","refund_money":"0.00","finish_time":1609584553,"small_change":"0.00"}]';
        $arr = json_decode($jsarr2,true);
        //   pre($arr);

        foreach ($arr as $key=>$value){
            $extends=db('divide_receives_user')->where('receives_id',$value['receives_id'])->value('extend');

            $data = json_decode($extends, true);
            if(count($data)>1){
                //把查询出来的数据转成数据

                //获取最后一个数组
//                $lastData=end($data);
                //   $this->log('最后一个数组',$lastData);
                //存在的话，把最后一个数组删除
                array_pop( $data);
                $res = json_encode($data);
                db('divide_receives_user')->where('receives_id',$value['receives_id'])->setField('extend',$res);
            }
        }

    }

    public function info(){
//        $totalAbonus=db('divide_receives')->where(['user_id'=>$user['user_id'],'wxapp_id'=>$this->wxapp_id])->sum('total_abonus');
//        //计算除了分红转化和提现的分销总金额
//
//        $dealerMoney = db('dealer_capital')
//            ->where(['user_id'=>$user['user_id'],'wxapp_id'=>$this->wxapp_id])
//            //->where(['flow_type'=>['<>',30],'flow_type'=>['<>',60]])
//            ->where('flow_type','not in','30,60')
//            ->sum('money');
//
//        $user['bonus']=bcadd($totalAbonus,$dealerMoney,2);
        $receivesIds=db('divide_receives')->where(['user_id'=>10006,'wxapp_id'=>1])->column('receives_id');

        $userRefundTotalMoney = 0;
        //循环记录id，查询分账记录详情，
        foreach ($receivesIds as $value){
            $userExtends=db('divide_receives_user')->where(['receives_id'=>$value])->value('extend');
            //将json数据格式转化成数组
            $data = json_decode($userExtends, true);

            //循环转化的数组，拿到type==1的退款金额
            foreach ($data as $item){
                if($item['type']==1){

                    $userRefundTotalMoney +=  $item['refund_fee'];
                }
            }
        }

        $dealerMoney = db('dealer_capital')
            ->where(['user_id'=>10006,'wxapp_id'=>1])
            ->where('flow_type','<>','60')
            ->sum('money');

    }


    protected function log($pre,$data = null)
    {
        if($data) {
            $data = is_array($data) ? json_encode($data) : $data;
            file_put_contents("fz-".date('Ymd', time()).".log",  $pre . $data .  "\n", FILE_APPEND);
        } else {
            file_put_contents("fz-".date('Ymd', time()).".log",  $pre .  "\n", FILE_APPEND);
        }

    }

    //写入结束时间
    public function ctime(){
        $setting=$this->getSetting(36);//获取本次分红设置
        $recivis=db('divide_receives')->where(['wxapp_id'=>$setting['wxapp_id'],'periods_num'=>$setting['periods_num'],'type'=>0])->select();

        foreach ($recivis as $value)
        {

            $endTime= $value['create_time']+($setting['term']*24*60*60);
            // return db('divide_receives')->where(['wxapp_id'=>$setting['wxapp_id'],'periods_num'=>$setting['periods_num']])->setField('finish_time',0);
            db('divide_receives')->where('receives_id',$value['receives_id'])->setField('finish_time',$endTime);
        }


    }

    public function bonus111(){

        $userList=collection(db('divide_receives')
            ->where(['wxapp_id'=>40,'type'=>0,'periods_num'=>1000])
            ->where('receives_id','<',1847)
            ->field('receives_id,type,order_no, times,balance,wxapp_id,payment,periods_num,user_id,account,top_limit,transaction_id')
            ->order('create_time desc')
            ->select())->toArray();
        //pre($userList); 
        foreach($userList as $key=>$item){
            //将用户的剩余金额转换成零钱
            $this->setUserBlance($item['balance'],$item);
            //将用户出局
            $this->setUserUpdata(3,$item['receives_id'],$item['balance'],$item['times']);
            //经数据写入附表
            $this->setReceivesUserAccounts(2,2,$item['receives_id'],0,$item['balance'],1,0);

        }
    }

    public function infos(){
        $receivesIds=db('divide_receives')->where(['user_id'=>10006,'wxapp_id'=>1])->column('receives_id');
        var_dump($receivesIds);
        $userRefundTotalMoney = 0;
        if(!empty($receivesIds) && $receivesIds!==null && $receivesIds !==0 ){

            //当是数组的时候
            if(is_array($receivesIds)){
                //循环记录id，查询分账记录详情，
                foreach ($receivesIds as $value){

                    $userExtends=db('divide_receives_user')->where(['receives_id'=>$value])->value('extend');

                    if($userExtends){

                        //将json数据格式转化成数组
                        $data = json_decode($userExtends, true);
                        //循环转化的数组，拿到type==1的退款金额
                        foreach ($data as $item){
                            if($item['type']==1){
                                $userRefundTotalMoney +=  $item['refund_fee'];
                            }
                        }

                    }else{

                        $userRefundTotalMoney +=0;
                    }

                }
            }else{
                //非数组的时候
                $userExtends=db('divide_receives_user')->where(['receives_id'=>$receivesIds])->value('extend');
                if($userExtends){

                    //将json数据格式转化成数组
                    $data = json_decode($userExtends, true);
                    //循环转化的数组，拿到type==1的退款金额

                    foreach ($data as $item){
                        if($item['type']==1){
                            $userRefundTotalMoney +=  $item['refund_fee'];
                        }
                    }


                }else{

                    $userRefundTotalMoney +=0;
                }
            }

            $dealerMoney = db('dealer_capital')
                ->where(['user_id'=>10006,'wxapp_id'=>19])
                ->where('flow_type','<>','60')
                ->sum('money');

        }
        var_dump($userRefundTotalMoney);
        var_dump($dealerMoney);
        $bonus =bcadd($userRefundTotalMoney, $dealerMoney,2);
        var_dump($bonus);
        $user['bonus'] =$bonus ? $bonus : 0;
        var_dump($user['bonus']);
    }


    public function index111(){
        $params=$this->request->param();
        $order=$this->getOrderInfo($params['order_no']);//获取订单信息
        $setting=$this->getSetting($order['wxapp_id']);//获取本次分红设置
        $userMoney=$params['user_money'];//计算用户的分红金额
        $receivesId=$params['receives_id'];
        //调用用户退款
        $this->getMultipleBackAbonus($order,$setting,$userMoney,$receivesId);

    }

    private function getMultipleBackAbonus($order,$setting,$userMoney,$receivesId){

        $this->log('11 用户退款逻辑开始...');
        $userList=collection(db('divide_receives')
            ->where(['wxapp_id'=>$order['wxapp_id'],'type'=>0,'periods_num'=>$setting['periods_num']])
            //->where('create_time','<',$order['create_time'])
            ->where('receives_id','<', $receivesId)
            ->field('receives_id,type,order_no, times,balance,wxapp_id,payment,periods_num,user_id,account,top_limit,transaction_id')
            ->order('create_time desc')
            ->select())->toArray();

        $this->setRefundUsersBackAccounts($userList,$userMoney,$order,$setting);
    }








    /**
     * 退还之前的用户分红
     * @param $userList
     * @param $userMoney
     * @param $order
     * @param $setting
     * @throws BaseException
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    private function setRefundUsersBackAccounts($userList,$userMoney,$order,$setting){
        $this->log('50-1 接入分红用户数据',$userList);
        $this->log('50-2 接入用户分红金额',$userMoney);
        $this->log('50-3 接入分红订单数据',$order);
        $this->log('50-4 接入商家分红设置',$setting);
        foreach ($userList as $key=>$item){
            $this->log('50-5 接入商家分红设置',$userMoney);
            if($item['balance']<$userMoney){

                $this->log('50-5-1 接入商家分红设置',$userMoney);
                //计算用户的实际分红金额
                // $userRealMoney=bcsub($userMoney,$item['balance'],2);
                if($item['times']>=46){
                    // pre(1);
                    $reas=$this->setUserDealer($item['balance'],$item);
                    $this->log('50-5-1-1 用户信息',$item);
                    if($reas==1){
                        //修改主表数据
                        $this->setUserUpdata(2,$item['receives_id'],$item['balance']);
                        //经数据写入附表
                        $this->setReceivesUserAccounts(2,2,$item['receives_id'],0,$item['balance'],1,0);
                        //将退完款的人出局
                        $this->setUserOutAccounts($item['receives_id'],$item['user_id']);
                        //退出微股东
                        // $this->noUserShareholderAccounts($item['user_id']);
                    }else{

                        //用户退款失败表
                        $this->setUserRefund($order,$setting,'写入数据失败',$item['balance'],$item['periods_num']);
                    }


                }else{
                    //  pre(2);
                    // 退换剩余的分红实际金额
                    $reas= $this->getOneUserBackAbonus($item['wxapp_id'],$item['transaction_id'],$item['payment'],$item['balance']);
                    if($reas['return_code']=='SUCCESS' && $reas['result_code']=='SUCCESS'){
                        //修改主表数据
                        $this->setUserUpdata(1,$item['receives_id'],$item['balance']);

                        //经数据写入附表,（1.第一次，2是多次），（1是现金,2是赏金），主表id，退款等单号，实际退款金额，退款状态
                        $this->setReceivesUserAccounts(2,1,$item['receives_id'],$reas['refund_id'],$item['balance'],1,0);

                        //将退完款的人出局
                        $this->setUserOutAccounts($item['receives_id'],$item['user_id']);
                        //退出微股东
                        //$this->noUserShareholderAccounts($item['user_id']);

                    }else{
                        //用户退款失败表
                        $this->setUserRefund($order,$setting,$reas['err_code_des'],$item['balance'],$item['periods_num']);
                    }
                }


            }elseif($item['balance']==$userMoney){

                $this->log('50-5-2 接入商家分红设置',$userMoney);
                if($item['times']>=46){
                    // pre(3);
                    //将剩余的资金退还到用户赏金账户
                    $reas=$this->setUserDealer($userMoney,$item);
                    $this->log('50-5-2-1 用户信息',$item);
                    if($reas==1){
                        //修改主表数据
                        $this->setUserUpdata(2,$item['receives_id'],$item['balance']);
                        //经数据写入附表
                        $this->setReceivesUserAccounts(2,2,$item['receives_id'],0,$userMoney,1,0);

                        //将退完款的人出局
                        $this->setUserOutAccounts($item['receives_id'],$item['user_id']);
                        //退出微股东
                        //$this->noUserShareholderAccounts($item['user_id']);
                    }else{

                        //用户退款失败表
                        $this->setUserRefund($order,$setting,'写入数据失败',$userMoney,$item['periods_num']);
                    }

                }else{
                    //pre(4);
                    // 退换剩余的分红实际金额
                    $reas= $this->getOneUserBackAbonus($item['wxapp_id'],$item['transaction_id'],$item['payment'],$userMoney);
                    if($reas['return_code']=='SUCCESS' && $reas['result_code']=='SUCCESS'){
                        //修改主表数据
                        $this->setUserUpdata(1,$item['receives_id'],$userMoney);

                        //经数据写入附表,（1.第一次，2是多次），（1是现金,2是赏金），主表id，退款等单号，实际退款金额，退款状态
                        $this->setReceivesUserAccounts(2,1,$item['receives_id'],$reas['refund_id'],$userMoney,1,0);

                        //将退完款的人出局
                        $this->setUserOutAccounts($item['receives_id'],$item['user_id']);
                        //退出微股东
                        // $this->noUserShareholderAccounts($item['user_id']);
                    }else{
                        //用户退款失败表
                        $this->setUserRefund($order,$setting,$reas['err_code_des'],$userMoney,$item['periods_num']);

                    }

                }


            }elseif($item['balance']>$userMoney){

                $this->log('50-5-3 接入商家分红设置',$userMoney);
                if($item['times']>=46){
                    //  pre(5);
                    $reas=$this->setUserDealer($userMoney,$item);
                    $this->log('50-5-3-1 用户信息',$item);
                    if($reas==1){
                        //修改主表数据
                        $this->setUserUpdata(2,$item['receives_id'],$userMoney);
                        //经数据写入附表
                        $this->setReceivesUserAccounts(2,2,$item['receives_id'],0,$userMoney,1,0);
                        //将用户设置为微股东
                        $this->setUserShareholderAccounts($order['user_id']);

                    }else{

                        //用户退款失败表
                        $this->setUserRefund($order,$setting,'写入数据失败',$userMoney,$item['periods_num']);
                    }
                }else{
                    // pre(6);
                    // 退换剩余的分红实际金额
                    $reas= $this->getOneUserBackAbonus($item['wxapp_id'],$item['transaction_id'],$item['payment'],$userMoney);
                    if($reas['return_code']=='SUCCESS' && $reas['result_code']=='SUCCESS'){
                        //修改主表数据
                        $this->setUserUpdata(1,$item['receives_id'],$userMoney);

                        //经数据写入附表,（1.第一次，2是多次），（1是现金,2是赏金），主表id，退款等单号，实际退款金额，退款状态,订单
                        $this->setReceivesUserAccounts(2,1,$item['receives_id'],$reas['refund_id'],$userMoney,1,0);
                        //将用户设置为微股东
                        $this->setUserShareholderAccounts($order['user_id']);

                    }else{
                        //用户退款失败表
                        $this->setUserRefund($order,$setting,$reas['err_code_des'],$userMoney,$item['periods_num']);

                    }
                }
            }

        }
    }


    /**
     *  将系统分红写入数据表
     * @param $periods_num string 分红期号
     * @param $order array 订单信息
     */
    private function setSystenAccounts($order,$periods_num){

        //获取系统服务商信息
        $systemConfig=BaseSetting::getItem('wechat');
        $system['account']            =$systemConfig['mch_id'];//服务商商户id
        $system['order_no']           =$order['order_no'];//订单号
        $system['wxapp_id']           =$order['wxapp_id'];//微信小程序内部编号
        $system['abonus']             =bcmul($order['pay_price'],0.01,2);//分账可得金额(单位/分)

        if(intval(bcmul($order['pay_price'],0.01,2)*100)>=8){
            $system['amount']             =bcmul(bcmul($order['pay_price'],0.01,2),0.2,2);//分账可得金额(单位/分)
        }else{
            $system['amount']             =$order['pay_price']*0.01;//分红金额(单位/分)
        }
        $system['description']        ='分账给系统服务商';
        $system['payment']            =$order['pay_price'];//实际支付总金额(单位/分)
        $system['transaction_id']     =$order['transaction_id'];//微信内部订单
        $system['status']             =0;//结算状态 0待分账 1已分账 2分账失败
        $system['create_time']        =time();//写入时间
        $system['periods_num']        =$periods_num;//期号
        return db('divide_system')->insert($system);
    }

    /**
     * @param $order array 订单信息
     * @param $periods_num  string   分红期号
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    private function setOperateCenterAccounts($order,$periods_num){
        //获取服务商的id
        $agentId=db('wxapp')->where(['wxapp_id'=>$order['wxapp_id']])->value('agent_id');

        if ($agentId!==0){
            $agentList=collection(db('agent')->where(['is_recycle'=>0,'status'=>1,'is_delete'=>0])->order('agent_id desc')->select())->toArray();//合伙人层级
            if (!empty($agentList)){
                $tree =Services::instance();
                $tree->init($agentList, 'recommend_id');
                $agentData=$tree->getParents($agentId,true);
                $agentCount=count($agentData);

                $agentDividendsDataArray=[];
                if($agentCount==1){
                    $agentDividendsDataArray['name']          = $agentData[0]['company_name'];
                    $agentDividendsDataArray['type']          = 1;
                    $agentDividendsDataArray['agent_id']      = $agentData[0]['agent_id'];
                    // $agentDividendsDataArray['proportion']    = $agentData[0]['service_charge'];
                    $agentDividendsDataArray['amount']        = bcmul(($agentData[0]['service_charge']/100),($order['pay_price']*0.01),2);
                    // $agentDividendsDataArray['description']   ='分账给品牌商';
                    //  $agentDividendsDataArray['trade']         = $trade;//分账单号，小程序号+期号+时间
                    $agentDividendsDataArray['abonus']        = bcmul($order['pay_price'],0.01,2);//参与分账金额
                    $agentDividendsDataArray['order_no']      = $order['order_no'];//订单号
                    $agentDividendsDataArray['payment']       = $order['pay_price'];//订单实际支付金额
                    $agentDividendsDataArray['transaction_id']= $order['transaction_id'];
                    $agentDividendsDataArray['wxapp_id']      = $order['wxapp_id'];//内部微信小程序编号
                    $agentDividendsDataArray['status']        = 0;//状态（0，未分账，1.已分账，2.分账失败）
                    $agentDividendsDataArray['create_time']   = time();//写入时间（支付时间）
                    $agentDividendsDataArray['periods_num']   = $periods_num;//写入时间（支付时间）
                    db('divide_service')->insert($agentDividendsDataArray);
                }elseif ($agentCount==2){
                    $agentDividendsDataArray[0]['name']          = $agentData[0]['company_name'];
                    $agentDividendsDataArray[0]['type']          = 1;
                    $agentDividendsDataArray[0]['agent_id']      = $agentData[0]['agent_id'];
                    $agentDividendsDataArray[0]['amount']        = bcmul((($agentData[0]['service_charge']-$agentData[1]['service_charge'])/100),bcmul($order['pay_price'],0.01,2),2);
                    $agentDividendsDataArray[0]['abonus']        = bcmul($order['pay_price'],0.01,2);//参与分账金额
                    $agentDividendsDataArray[0]['order_no']      = $order['order_no'];//订单号
                    $agentDividendsDataArray[0]['payment']       = $order['pay_price'];//订单实际支付金额
                    $agentDividendsDataArray[0]['transaction_id']= $order['transaction_id'];
                    $agentDividendsDataArray[0]['wxapp_id']      = $order['wxapp_id'];//内部微信小程序编号
                    $agentDividendsDataArray[0]['status']        = 0;//状态（0，未分账，1.已分账，2.分账失败）
                    $agentDividendsDataArray[0]['create_time']   = time();//写入时间（支付时间）
                    $agentDividendsDataArray[0]['periods_num']   = $periods_num;//写入时间（支付时间）
                    if($agentData[1]['type']==1){
                        //分账给运营商
                        $agentDividendsDataArray[1]['name']          = $agentData[1]['company_name'];
                        $agentDividendsDataArray[1]['type']          = 2;
                        $agentDividendsDataArray[1]['agent_id']      = $agentData[1]['agent_id'];
                        $agentDividendsDataArray[1]['amount']        = bcmul(($agentData[1]['service_charge']/100),bcmul($order['pay_price'],0.01,2),2);
                        $agentDividendsDataArray[1]['abonus']        = bcmul($order['pay_price'],0.01,2);//参与分账金额
                        $agentDividendsDataArray[1]['order_no']      = $order['order_no'];//订单号
                        $agentDividendsDataArray[1]['payment']       = $order['pay_price'];//订单实际支付金额
                        $agentDividendsDataArray[1]['transaction_id']= $order['transaction_id'];
                        $agentDividendsDataArray[1]['wxapp_id']      = $order['wxapp_id'];//内部微信小程序编号
                        $agentDividendsDataArray[1]['status']        = 0;//状态（0，未分账，1.已分账，2.分账失败）
                        $agentDividendsDataArray[1]['create_time']   = time();//写入时间（支付时间）
                        $agentDividendsDataArray[1]['periods_num']   = $periods_num;//写入时间（支付时间）
                    }elseif ($agentData[1]['type']==2){
                        //分账给合伙人
                        $agentDividendsDataArray[1]['name']          = $agentData[1]['real_name'];
                        $agentDividendsDataArray[1]['type']          =3;
                        $agentDividendsDataArray[1]['agent_id']      =$agentData[1]['agent_id'];
                        $agentDividendsDataArray[1]['amount']        =bcmul(($agentData[1]['service_charge']/100),bcmul($order['pay_price'],0.01,2),2);
                        $agentDividendsDataArray[1]['abonus']        = bcmul($order['pay_price'],0.01,2);//参与分账金额
                        $agentDividendsDataArray[1]['order_no']      = $order['order_no'];//订单号
                        $agentDividendsDataArray[1]['payment']       = $order['pay_price'];//订单实际支付金额
                        $agentDividendsDataArray[1]['transaction_id']= $order['transaction_id'];
                        $agentDividendsDataArray[1]['wxapp_id']      = $order['wxapp_id'];//内部微信小程序编号
                        $agentDividendsDataArray[1]['status']        = 0;//状态（0，未分账，1.已分账，2.分账失败）
                        $agentDividendsDataArray[1]['create_time']   = time();//写入时间（支付时间）
                        $agentDividendsDataArray[1]['periods_num']   = $periods_num;//写入时间（支付时间）
                    }
                    db('divide_service')->insertAll($agentDividendsDataArray);

                }elseif($agentCount==3){
                    $agentDividendsDataArray[0]['name']          = $agentData[0]['company_name'];
                    $agentDividendsDataArray[0]['type']          = 1;
                    $agentDividendsDataArray[0]['agent_id']      = $agentData[0]['agent_id'];
                    $agentDividendsDataArray[0]['amount']        = bcmul((($agentData[0]['service_charge']-$agentData[1]['service_charge'])/100),bcmul($order['pay_price'],0.01,2),2);
                    $agentDividendsDataArray[0]['abonus']        = bcmul($order['pay_price'],0.01,2);//参与分账金额
                    $agentDividendsDataArray[0]['order_no']      = $order['order_no'];//订单号
                    $agentDividendsDataArray[0]['payment']       = $order['pay_price'];//订单实际支付金额
                    $agentDividendsDataArray[0]['transaction_id']= $order['transaction_id'];
                    $agentDividendsDataArray[0]['wxapp_id']      = $order['wxapp_id'];//内部微信小程序编号
                    $agentDividendsDataArray[0]['status']        = 0;//状态（0，未分账，1.已分账，2.分账失败）
                    $agentDividendsDataArray[0]['create_time']   = time();//写入时间（支付时间）
                    $agentDividendsDataArray[0]['periods_num']   = $periods_num;//写入时间（支付时间）

                    $agentDividendsDataArray[1]['name']          = $agentData[1]['company_name'];
                    $agentDividendsDataArray[1]['type']          = 2;
                    $agentDividendsDataArray[1]['agent_id']      = $agentData[1]['agent_id'];
                    $agentDividendsDataArray[1]['amount']        = bcmul((($agentData[1]['service_charge']-$agentData[2]['service_charge'])/100),bcmul($order['pay_price'],0.01,2),2);
                    $agentDividendsDataArray[1]['abonus']        = bcmul($order['pay_price'],0.01,2);//参与分账金额
                    $agentDividendsDataArray[1]['order_no']      = $order['order_no'];//订单号
                    $agentDividendsDataArray[1]['payment']       = $order['pay_price'];//订单实际支付金额
                    $agentDividendsDataArray[1]['transaction_id']= $order['transaction_id'];
                    $agentDividendsDataArray[1]['wxapp_id']      = $order['wxapp_id'];//内部微信小程序编号
                    $agentDividendsDataArray[1]['status']        = 0;//状态（0，未分账，1.已分账，2.分账失败）
                    $agentDividendsDataArray[1]['create_time']   = time();//写入时间（支付时间）
                    $agentDividendsDataArray[1]['periods_num']   = $periods_num;//写入时间（支付时间）


                    $agentDividendsDataArray[2]['name']          = $agentData[2]['real_name'];
                    $agentDividendsDataArray[2]['type']          = 3;
                    $agentDividendsDataArray[2]['agent_id']      = $agentData[2]['agent_id'];
                    $agentDividendsDataArray[2]['amount']        = bcmul(($agentData[2]['service_charge']/100),bcmul($order['pay_price'],0.01,2),2);
                    $agentDividendsDataArray[2]['abonus']        = bcmul($order['pay_price'],0.01,2);//参与分账金额
                    $agentDividendsDataArray[2]['order_no']      = $order['order_no'];//订单号
                    $agentDividendsDataArray[2]['payment']       = $order['pay_price'];//订单实际支付金额
                    $agentDividendsDataArray[2]['transaction_id']= $order['transaction_id'];
                    $agentDividendsDataArray[2]['wxapp_id']      = $order['wxapp_id'];//内部微信小程序编号
                    $agentDividendsDataArray[2]['status']        = 0;//状态（0，未分账，1.已分账，2.分账失败）
                    $agentDividendsDataArray[2]['create_time']   = time();//写入时间（支付时间）
                    $agentDividendsDataArray[2]['periods_num']   = $periods_num;//写入时间（支付时间）
                    db('divide_service')->insertAll($agentDividendsDataArray);
                }

            }
        }


    }

    /**
     *   将商户的分红金额入库
     * @param $order  array 订单信息
     * @param $setting array 分红信息
     * @param $periods_num int 分红期号
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    private function setStoreAccounts($order,$setting,$periods_num){

        $storeConfig=db('wxapp')->where('wxapp_id',$order['wxapp_id'])->find();
        $store['account']            =$storeConfig['mchid'];//服务商商户id
        //   $store['trade']              =$trade;//分红账号
        $store['order_no']           =$order['order_no'];//订单号
        $store['wxapp_id']           =$order['wxapp_id'];//微信小程序内部编号
        if($periods_num==0){
            $store['amount']         =bcsub($order['pay_price'],bcmul($order['pay_price'],0.01));
            //  $store['proportion']     =bcdiv($store['amount'],$order['pay_price'],3);//分账比例（百分比）
        }else{
            $store['amount']         =bcmul($order['pay_price'],($setting['realmoney']/100),2);
            //    $store['proportion']     =$this->setting['realmoney'];//分账比例（百分比）
        }
        $store['agent_id']           = $storeConfig['agent_id'];
        // $store['description']        ='分账给商户';
        $store['payment']            =$order['pay_price'];//实际支付总金额(单位/分)
        $store['transaction_id']     =$order['transaction_id'];//微信内部订单
        $store['status']             =0;//结算状态 0待分账 1已分账 2分账失败
        $store['create_time']        =time();//写入时间
        $store['periods_num']        =$periods_num;//期号
        db('divide_store')->insert($store);
    }


    /**
     * 将退款用户写入数据库
     * @param $type
     * @param $trade
     * @param $userMoney
     * @param $order
     * @param $periodsNum
     * @param $setting
     */
    private function setUserBackAccounts($setting,$order,$userMoney,$periodsNum){
        $userListData['user_id']         = $order['user_id'] ;
        $userListData['account']         = $this->getUserOpenId($order['user_id'],$order['wxapp_id']) ;
        // $userListData['trade']           = $trade;//分账单号
        $userListData['order_no']        = $order['order_no'] ;//订单号
        $userListData['wxapp_id']        = $order['wxapp_id'];//微信小程序id
        // $userListData['amount']          = $userMoney;
        $userListData['payment']         = $order['pay_price'] ;//订单支付金额
        $userListData['periods_num']     = $periodsNum ;//活动期号
        $userListData['transaction_id']  = $order['transaction_id'] ;//订单号
        $userListData['top_limit']       = bcmul(($setting['upline']/100),$order['pay_price'],2);//用户分红上限
        if(intval($userMoney*100)<1){
            $userListData['balance']     = $userListData['top_limit'];//用户剩余分红金额
            $userListData['total_abonus']= $userMoney;//用户累计分红金额
            $userListData['times']       = 0;//参与分红的次数
        }else{
            $userListData['balance']     = bcsub($userListData['top_limit'],$userMoney,2);//用户剩余分红金额
            $userListData['total_abonus']= $userMoney;////用户累计分红金额
            $userListData['times']       = 1;//参与分红的次数
        }
        // $userListData['times']           = 1;//参与分红的次数
        $userListData['type']            = 0;//是否参与分账，0，参与，1.不参与
        $userListData['create_time']     = time();//写入时间（支付时间）
        $userListData['update_time']     = time();//写入时间（支付时间）
        return db('divide_receives')->insertGetId($userListData);
    }

    /**
     *  修改主表数据
     * 1.微信退款，2.赏金退款，3.零钱退款
     * @param $receivesId
     * @param $userMoney
     * @return int|string
     */
    private function setUserUpdata($type,$receivesId,$userMoney){

        if($type==1){
            return db('divide_receives')->where('receives_id',$receivesId)->setField(['balance'=>Db::raw('balance -'.$userMoney),'total_abonus'=>Db::raw('total_abonus +'.$userMoney),'refund_money'=>Db::raw('refund_money +'.$userMoney),'times'=>Db::raw('times + 1')]);
        }elseif ($type==2){
            return db('divide_receives')->where('receives_id',$receivesId)->setField(['balance'=>Db::raw('balance -'.$userMoney),'total_abonus'=>Db::raw('total_abonus +'.$userMoney),'reward_money'=>Db::raw('reward_money +'.$userMoney),'times'=>Db::raw('times + 1')]);
        }else{
            return db('divide_receives')->where('receives_id',$receivesId)->setField(['balance'=>Db::raw('balance -'.$userMoney),'total_abonus'=>Db::raw('total_abonus +'.$userMoney),'small_change'=>Db::raw('small_change +'.$userMoney),'times'=>Db::raw('times + 1'),'type'=>1,'finish_time'=>time()]);
        }


    }
    /**
     * 将每次的流水写入记录
     * @param $type int 第几次写入
     * @param $refund_type int 退款类型 1.现金 2.赏金
     * @param $receivesId  int 主表id
     * @param $refundId   int   退款订单id
     * @param $userMoney  float 用户退款金额
     * @param $status    int  是否成功
     * @param $times    int  次数
     * @param $order_no    int  产生退款的订单编号
     * @return int|string
     */
    private function setReceivesUserAccounts($type, $refund_type, $receivesId, $refundId, $userMoney, $status, $order){
        //第一次写入记录
        if($order!==0){
            if ($type==1){
                $userListData['receives_id']     = $receivesId;//主表id
                $userListData['extend']=json_encode([[
                                                         'type' =>$refund_type,//退款类型 1.微信现金退款
                                                         'refund_id'=>$refundId, //微信内部退款订单号
                                                         'refund_fee'=>$userMoney,//退款金额
                                                         'money'=>$order['pay_price'],//本次订单支付金额
                                                         'order_no'=>$order['order_no'],//产生退款的订单编号
                                                         'status'=>$status,    //退款状态 1.退款成功
                                                         'times' =>1,//第几次退款
                                                         'time' =>time()
                                                     ]]);
                $userListData['create_time']     = time();//写入时间（支付时间）
                return db('divide_receives_user')->insert($userListData);
            }else{
                $extend[]=[
                    'type' =>$refund_type,//退款类型 1.微信现金退款
                    'refund_id'=>$refundId, //微信内部退款订单号
                    'refund_fee'=>$userMoney,//退款金额
                    'money'=>$order['pay_price'],//本次订单支付金额
                    'order_no'=>$order['order_no'],//产生退款的订单编号
                    'status'=>$status,    //退款状态 1.退款成功
                    // 'times' => $times,//第几次退款
                    'time' =>time()
                ];
                $extends=db('divide_receives_user')->where('receives_id',$receivesId)->value('extend');
                if($extends){
                    $data = json_decode($extends, true);
                    //最后一个数组
                    $lastData=end($data);
                    //print_r($lastData);
                    if(!isset($lastData['times'])){
                        $extend[0]['times']=1;
                    }else{
                        $extend[0]['times']=$lastData['times']+1;
                    }
                    // print_r($extend);
                    $json =array_merge($data,$extend);
                    //  pre($json);
                    $res = json_encode($json );
                    return db('divide_receives_user')->where('receives_id',$receivesId)->setField('extend',$res);
                }else{
                    $userListData['receives_id']     = $receivesId;//主表id
                    $userListData['extend']=json_encode([[
                                                             'type' =>$refund_type,//退款类型 1.微信现金退款
                                                             'refund_id'=>$refundId, //微信内部退款订单号
                                                             'refund_fee'=>$userMoney,//退款金额
                                                             'money'=>$order['pay_price'],//本次订单支付金额
                                                             'order_no'=>$order['order_no'],//产生退款的订单编号
                                                             'status'=>$status,    //退款状态 1.退款成功
                                                             'times' =>1,//第几次退款
                                                             'time' =>time()]]);
                    $userListData['create_time']     = time();//写入时间（支付时间）
                    return db('divide_receives_user')->insert($userListData);
                }
            }
        }else{
            if ($type==1){
                $userListData['receives_id']     = $receivesId;//主表id
                $userListData['extend']=json_encode([[
                                                         'type' =>$refund_type,//退款类型 1.微信现金退款
                                                         'refund_id'=>$refundId, //微信内部退款订单号
                                                         'refund_fee'=>$userMoney,//退款金额
                                                         // 'money'=>$order['pay_price'],//本次订单支付金额
                                                         // 'order_no'=>$order['order_no'],//产生退款的订单编号
                                                         'status'=>$status,    //退款状态 1.退款成功
                                                         'times' =>1,//第几次退款
                                                         'time' =>time()
                                                     ]]);
                $userListData['create_time']     = time();//写入时间（支付时间）
                return db('divide_receives_user')->insert($userListData);
            }else{
                $extend[]=[
                    'type' =>$refund_type,//退款类型 1.微信现金退款
                    'refund_id'=>$refundId, //微信内部退款订单号
                    'refund_fee'=>$userMoney,//退款金额
                    //  'money'=>$order['pay_price'],//本次订单支付金额
                    //  'order_no'=>$order['order_no'],//产生退款的订单编号
                    'status'=>$status,    //退款状态 1.退款成功
                    // 'times' => $times,//第几次退款
                    'time' =>time()
                ];
                $extends=db('divide_receives_user')->where('receives_id',$receivesId)->value('extend');
                if($extends){
                    $data = json_decode($extends, true);
                    //最后一个数组
                    $lastData=end($data);
                    //print_r($lastData);
                    if(!isset($lastData['times'])){
                        $extend[0]['times']=1;
                    }else{
                        $extend[0]['times']=$lastData['times']+1;
                    }
                    // print_r($extend);
                    $json =array_merge($data,$extend);
                    //  pre($json);
                    $res = json_encode($json );
                    return db('divide_receives_user')->where('receives_id',$receivesId)->setField('extend',$res);
                }else{
                    $userListData['receives_id']     = $receivesId;//主表id
                    $userListData['extend']=json_encode([[
                                                             'type' =>$refund_type,//退款类型 1.微信现金退款
                                                             'refund_id'=>$refundId, //微信内部退款订单号
                                                             'refund_fee'=>$userMoney,//退款金额
                                                             // 'money'=>$order['pay_price'],//本次订单支付金额
                                                             // 'order_no'=>$order['order_no'],//产生退款的订单编号
                                                             'status'=>$status,    //退款状态 1.退款成功
                                                             'times' =>1,//第几次退款
                                                             'time' =>time()]]);
                    $userListData['create_time']     = time();//写入时间（支付时间）
                    return db('divide_receives_user')->insert($userListData);
                }
            }
        }

    }

    /**
     * 用户退款失败
     * @param $order
     * @param $setting
     * @param $res
     * @param $trade
     * @param $userMoney
     * @param $periodsNum
     * @return int|string
     */
    private  function setUserRefund($order,$setting,$res,$userMoney,$periodsNum){
        $userListData['user_id']         = $order['user_id'] ;
        $userListData['account']         = $this->getUserOpenId($order['user_id'],$order['wxapp_id']) ;
        // $userListData['trade']           = $trade;//分账单号
        $userListData['order_no']        = $order['order_no'] ;//订单号
        $userListData['wxapp_id']        = $order['wxapp_id'];//微信小程序id
        $userListData['amount']          = $userMoney;
        $userListData['payment']         = $order['pay_price'] ;//订单支付金额
        $userListData['periods_num']     = $periodsNum ;//活动期号
        $userListData['transaction_id']  = $order['transaction_id'] ;//订单号
        $userListData['top_limit']       = bcmul(($setting['upline']/100),$order['pay_price']);//用户分红上限
        $userListData['type']            = 0;//是否参与分账，0，参与，1.不参与
        $userListData['status']          = 2;//用户退款，0、待分账，1.已分账，2.分账失败
        $userListData['fail_reason']     = $res;//是否参与分账，0，参与，1.不参与
        $userListData['create_time']     = time();//写入时间（支付时间）
        $userListData['update_time']     = time();//写入时间（支付时间）
        return db('divide_refund')->insert($userListData);
    }

    //分账失败
    private function setSystemAbonus($orderNo,$reason){
        db('divide_system')->where('order_no',$orderNo)->setField(['status'=>2,'fail_reason'=>$reason]);
        db('divide_store')->where('order_no',$orderNo)->setField(['status'=>2,'fail_reason'=>$reason]);
        db('divide_service')->where('order_no',$orderNo)->setField(['status'=>2,'fail_reason'=>$reason]);
    }

    /**
     *  将参与分红的会员转化成为微股东
     * @param $userId
     */
    private function setUserShareholderAccounts($userId){
        return  db('user')->where('user_id',$userId)->setField('shareholder',1);
    }

    private function noUserShareholderAccounts($userId){
        return  db('user')->where('user_id',$userId)->setField('shareholder',0);
    }

    /**
     * 将退款完账的人出局
     * @param $trade
     */
    private function setUserOutAccounts($receivesId){
        return  db('divide_receives')->where('receives_id',$receivesId)->setField(['type'=>1,'finish_time'=>time()]);
    }


    /**
     *  参与分红代言人可以分到的钱
     * @param $totalMoney
     * @return float|int
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    private function getUserMoney($order,$setting){
        $totalUserMoney=$order['pay_price']*((1-($setting['realmoney']/100)-0.01));//用户总的分账金额
        //$totalUserMoney=bcmul($order['pay_price'],(1-($setting['realmoney']/100)-0.01));//用户总的分账金额
        //参与分红的代言人
        // $staff=$this->getStoreStaffDivideCount($order);
        //如果代言人参与分红
        // if($staff!==false){
        //   $userCount=intval($this->getUserAccounts($order['wxapp_id'],$setting['periods_num']))+1+$staff;//分账用户总数,加入本次出账方一人和商铺代言人
        //}else{
        $userCount=intval($this->getUserAccounts($order['wxapp_id'],$setting['periods_num']))+1;//分账用户总数,加入本次的出账方一人

        // }
        $userMoney=substr(sprintf("%.3f",($totalUserMoney/$userCount)),0,-1);//单个用户分账的金额
        return $userMoney;//单位分
    }
    /***
     *  统计参与分账的代言人
     * @return bool|int|string
     * @throws \think\Exception
     */
    private function getStoreStaffDivideCount($order){
        return db('store_shop_clerk')->where(array('wxapp_id'=>$order['wxapp_id'],'type'=>1,'shop_id'=>$order['extract_shop_id']))->count();
    }

    /**
     * 统计参与分红的用户
     * @param $wxappId
     * @param $periodsNum
     * @return int|string
     * @throws \think\Exception
     */
    private function getUserAccounts($wxappId,$periodsNum){

        return db('divide_receives')->where(['wxapp_id'=>$wxappId,'type'=>0,'periods_num'=>$periodsNum])->count();

    }

    /**
     * 获取用户的open_id
     * @param $userId int 用户id
     * @param $wxappId int 微信id
     * @return bool|float|mixed|string|null
     */

    private function getUserOpenId($userId,$wxappId){
        return db('user')->where(['user_id'=>$userId,'wxapp_id'=>$wxappId])->value('open_id');
    }

    /**
     * 获取订单详情
     * @param $orderNo
     * @return array|bool|false|\PDOStatement|string|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getOrderInfo($orderNo){
        return  db('order')->where('order_no',$orderNo)->find();

    }

    /**
     *  获取设置信息
     * @param $wxappId
     * @return array|bool|false|\PDOStatement|string|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    private function getSetting($wxappId){
        return  db('wxapp_setting')->where('wxapp_id',$wxappId)->find();
    }
    /**
     * 调用退款接口
     * @param $transaction_id
     * @param $payment
     * @param $userMoney
     * @return bool
     * @throws BaseException
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    private function getOneUserBackAbonus($wxappId,$transaction_id,$payment,$userMoney){

        $wxConfig = WxappModel::getWxappRedis($wxappId);

        //获取证书
        if (empty($wxConfig['mchid']) || empty($wxConfig['app_id'])) {
            throw new BaseException(['msg' => '请先到后台小程序设置填写微信支付相关内容']);
        }
        $WxPay = new WxPay($wxConfig);
        return $WxPay->refund($transaction_id,$payment,$userMoney); //用户分红回退
    }


    /**
     *  参与分红的商户店员写入数据库
     * @param $order array  订单信息
     * @param $setting array  设置信息
     * @param $money int  跟随用户分红的时候的分红金额
     * @param $proportion int 跟随用户分红的时候的分红比例
     * @param $totalMoney int 总支付金额
     * @return bool
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    private function setStoreStaffAccounts($order,$setting,$money,$proportion,$totalMoney){

        $staffUserList=db('store_shop_clerk')->where(array('wxapp_id'=>$order['wxapp_id'],'type'=>1,'shop_id'=>$order['extract_shop_id']))->field('clerk_id,open_id,abonus')->select();
        if($staffUserList->isEmpty()){
            return false;
        }else{
            $staffUserDataArray=[];
            foreach ($staffUserList as $key=>$value){
                if($value['pay_type']==0){
                    $staffUserDataArray['amount']        =$money;
                    $staffUserDataArray['proportion']    =$proportion;//分账比例（百分比）
                }else{
                    $staffUserDataArray['amount']        =bcmul(($value['abonus']/100),bcmul($totalMoney,bcsub(1,($this->setting['term']/100))));
                    $staffUserDataArray['proportion']    = $value['abonus'];;//分账比例（百分比）
                }
                // $staffUserDataArray['trade']         =$trade;//代言人id
                $staffUserDataArray['order_no']      =$order['order_no'];//代言人id
                $staffUserDataArray['wxapp_id']      =$order['wxapp_id'];//代言人id
                $staffUserDataArray['clerk_id']      =$value['clerk_id'];//代言人id
                $staffUserDataArray['account']       =$value['open_id'];
                $staffUserDataArray['description']   ='分账给商户代言人';
                $staffUserDataArray['payment']       =$order['pay_price'];
                $staffUserDataArray['periods_num']   =$setting['periods_num'];
                $staffUserDataArray['transaction_id']=$order['transaction_id'];//代言人id
                $staffUserDataArray['status']        =0;
                $staffUserDataArray['create_time']   =time();

            }
            db('divide_store_clerk')->insertAll($staffUserDataArray);
        }
    }




    /**
     *   * 将用户多余的积分给用户加上
     * @param $chage  int 零钱
     * @param $item  int  订单
     * @throws \think\Exception
     */
    private function setUserBlance($chage,$item){
        $userModel=new User();
        $res=$userModel->where('user_id',$item['user_id'])->setInc('balance',$chage);
        if($res){
            // 用户余额变动明细
            BalanceLog::add(50, [
                'user_id'  =>$item['user_id'],
                'money'    =>+$chage,
                'wxapp_id' =>$item['wxapp_id'],
            ], ['order_no' =>$item['order_no']]);
        }

    }

    /**
     *  将用户分不了的金额转化成赏金
     * @param $chage
     * @param $item
     * @throws \think\Exception
     */
    private function setUserDealer($chage,$item){
        $userModel=new \app\common\model\dealer\User();

        $res=$userModel->where(['user_id'=>$item['user_id'],'wxapp_id'=>$item['wxapp_id']])->fetchSql(false)->setInc('money',$chage);

        if($res){
            // 用户余额变动明细
            Capital::add([
                'wxapp_id' =>$item['wxapp_id'],
                'user_id'  =>$item['user_id'],
                'flow_type'=>30,
                'money'    =>+$chage,
                'describe' =>'分红转换'
            ]);
            return $res;
        }

    }


}